Mining problem...

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
izidor
Veteran
Posts: 110
Joined: Wed Apr 22, 2009 3:13 am
Contact:

Mining problem...

Post by izidor »

Post including QB64 code!

A few moths ago i have made a little game called Mining. Basically you are a funny looking dude with a pickaxe. Lets put the story on the side and start with my problem :) I'm not sure why don't the tiles appear in upper left corner, that's my problem.
Few thing that i have tried that aren't causing this are:

Changing x,y to 0 from 1

Code: Select all

FOR y = 1 to 7
    FOR x = 1 to 14
Removing BackGround.png

If you can't figure out what is the problem i will upload the game on Rapid Share on something like that.

Here is the code:

Code: Select all

'Screen mode
SCREEN 9

DIM titanmine(14, 7)

_TITLE "Mining v.1.0"

'Loading images
miner = _loadimage("./System/Miner.png")
ground = _loadimage("./System/Ground.png")
wall = _loadimage("./System/Wall.png")
bronze = _loadimage("./System/Bronze.png")
silver = _loadimage("./System/Silver.png")
coal = _loadimage("./System/Coal.png")
mithril = _loadimage("./System/Mithril.png")
furnice = _LOADIMAGE("./System/Furnice.png")

mine = _LOADIMAGE("./System/Mine.png")
quit = _LOADIMAGE("./System/Quit.png")
background = _LOADIMAGE("./System/BackGround.png")

CLS

_PUTIMAGE (0,0),background
_PUTIMAGE (462,297),quit
_PUTIMAGE (537,297),mine

RESTORE titanmine
FOR y = 1 to 7
    FOR x = 1 to 14
        READ titanmine(x,y)
NEXT : NEXT
FOR y = 1 to 7
    FOR x = 1 to 14

        IF titanmine(x,y) = -4 then _PUTIMAGE (x * 30, y * 41),furnice

        IF titanmine(x,y) = -3 then _PUTIMAGE (x * 30, y * 41),bronze

        IF titanmine(x,y) = -2 then _PUTIMAGE (x * 30, y * 41),silver

        IF titanmine(x,y) = -1 then _PUTIMAGE (x * 30, y * 41),coal

        IF titanmine(x,y) = 0 then _PUTIMAGE (x * 30, y * 41),mithril

        IF titanmine(x,y) = 1 then _PUTIMAGE (x * 30, y * 41),wall

        IF titanmine(x,y) = 2 then _PUTIMAGE (x * 30, y * 41),ground

        IF titanmine(x,y) = 3 then _PUTIMAGE (x * 30, y * 41),miner

        'trigers
        IF titanmine(x,y) = 4 then _PUTIMAGE (x * 30, y * 41),ground

        IF titanmine(x,y) = 5 then _PUTIMAGE (x * 30, y * 41),ground

        IF titanmine(x,y) = 6 then _PUTIMAGE (x * 30, y * 41),ground

        IF titanmine(x,y) = 7 then _PUTIMAGE (x * 30, y * 41),ground

NEXT : NEXT


X = 2
Y = 2

_PUTIMAGE(x * 30, y * 41),ground
_PUTIMAGE(x * 30, y * 41),miner

bronze = 0
silver = 0
coal = 0
mithril = 0
xp = 0
lvl = 1

LOCATE 15,60
PRINT "You can mine: "

COLOR 6
LOCATE 17,60
PRINT "Bronze at Lvl 1"
COLOR 7
LOCATE 18,60
PRINT "Silver at Lvl 5"
LOCATE 19,60
COLOR 8
PRINT "Coal at Lvl 10"
COLOR 1
LOCATE 20,60
PRINT "Mithus at Lvl 20"

Start:
DO

    COLOR 15
    LOCATE 5,60
    PRINT "Bronze: "
    LOCATE 5,68
    PRINT bronze

    LOCATE 6,60
    PRINT "Silver: "
    LOCATE 6,68
    PRINT silver

    LOCATE 7,60
    PRINT "Coal: "
    LOCATE 7,68
    PRINT coal

    LOCATE 8,60
    PRINT "Mithus: "
    LOCATE 8,68
    PRINT mithril

    LOCATE 12,60
    PRINT "Level: "
    LOCATE 12,67
    PRINT lvl
    LOCATE 13,60
    PRINT "XP: "
    LOCATE 13,64
    PRINT xp



    k$ = INKEY$

    IF titanmine(x,y) = 4 THEN
        gofurnace = 1
    END IF

    IF gofurnace = 1 THEN

    END IF

    'mining
    IF titanmine(x,y) = 4 AND lvl >= 1 AND k$ = "m" or k$ = "M" THEN

        LOCATE 10,60
        PRINT "Mining..."
        _DELAY 2
        LOCATE 10,60
        PRINT "         "
        bronze = bronze + 1
        xp = xp + 20

        ELSEIF titanmine(x,y) = 5 AND lvl >= 5 AND k$ = "m" or k$ = "M" THEN

        LOCATE 10,60
        PRINT "Mining..."
        _DELAY 2.5
        LOCATE 10,60
        PRINT "         "
        silver = silver + 1
        xp = xp + 50

        ELSEIF titanmine(x,y) = 6 AND lvl >= 10 AND k$ = "m" or k$ = "M" THEN

        LOCATE 10,60
        PRINT "Mining..."
        _DELAY 3.5
        LOCATE 10,60
        PRINT "         "
        coal = coal + 1
        xp = xp + 100

        ELSEIF titanmine(x,y) = 7 AND lvl >= 20 AND k$ = "m" or k$ = "M" THEN

        LOCATE 10,60
        PRINT "Mining..."
        _DELAY 4
        LOCATE 10,60
        PRINT "         "
        mithril = mithril + 1
        xp = xp + 200

    END IF


    IF xp >= 30  then lvl = 2
    IF xp >= 60  then lvl = 3
    IF xp >= 100  then lvl = 4
    IF xp >= 130  then lvl = 5
    IF xp >= 170  then lvl = 6
    IF xp >= 220  then lvl = 7
    IF xp >= 270  then lvl = 8
    IF xp >= 330  then lvl = 9
    IF xp >= 380  then lvl = 10
    IF xp >= 450  then lvl = 11
    IF xp >= 510  then lvl = 12
    IF xp >= 600  then lvl = 13
    IF xp >= 690  then lvl = 14
    IF xp >= 780  then lvl = 15
    IF xp >= 860  then lvl = 16
    IF xp >= 980  then lvl = 17
    IF xp >= 1020  then lvl = 18
    IF xp >= 1100  then lvl = 19
    IF xp >= 1380  then lvl = 20
    IF xp >= 1700  then lvl = 21
    IF xp >= 2100  then lvl = 22
    IF xp >= 2900  then lvl = 23
    IF xp >= 3850  then lvl = 24
    IF xp >= 4300  then lvl = 25
    IF xp >= 4650  then lvl = 26
    IF xp >= 5380  then lvl = 27
    IF xp >= 5900  then lvl = 28
    IF xp >= 6500  then lvl = 29
    IF xp >= 7000  then lvl = 30




    'walking
    px = x: py = y

    IF k$ = chr$(100) AND titanmine(x + 1,y) > 1 THEN x = x + 1

    IF k$ = chr$(97) AND titanmine(x - 1,y) > 1 THEN x = x - 1

    IF k$ = chr$(119) AND titanmine(x,y - 1) > 1 THEN y = y - 1

    IF k$ = chr$(115) AND titanmine(x,y + 1) > 1 THEN y = y + 1

    IF px <> x OR py <> y THEN
        _PUTIMAGE(x * 30, y * 41),miner
        _PUTIMAGE(px * 30, py * 41),ground
    END IF

    IF k$ = chr$(9) then
        locate 1,1
        INPUT ": ",a$
        if a$ = "game" then
            goto start
            PRINT "                                                              "
            elseif a$ = "god" then
            lvl = 40
            locate 1,1
            PRINT "                                                              "
        end if
    end if

LOOP UNTIL k$ = "q" or k$ = "Q"



titanmine:
DATA 1,1,1,1,1,1,1,1,1,1,1,1,1,1
DATA 1,2,2,6,-1,6,2,2,2,4,-3,1,2,1
DATA 1,6,2,2,6,6,2,2,2,6,4,1,2,1
DATA 1,-1,6,2,6,-1,6,2,6,-1,6,2,2,1
DATA 1,6,-1,6,2,6,7,2,2,6,2,2,5,1
DATA 1,2,6,2,2,7,0,7,2,2,2,5,-2,1
DATA 1,1,1,1,1,1,1,1,1,1,1,1,1,1


User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 »

1) Why is this NOT posted at the QB64.net site?
2) Why are files in a System folder?
3) Check for bad _LOADIMAGE handle values of -1

http://qb64.net/wiki/index.php?title=LOADIMAGE
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
izidor
Veteran
Posts: 110
Joined: Wed Apr 22, 2009 3:13 am
Contact:

Post by izidor »

1. I don't think that this is kind of post for QB64 site because there is no section for code problems (not QB64s). But it would be nice if Pete created QB64 section here.

2. Don't mind System folder

3. I will check it out, thanks.
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 »

There are two forums there. Discussion Forum if you think it might be a QB64 related and the Non-QB64 Forum for QB related problems. Also a Bug Forum if you really do find a problem in QB64 and not your code.

You only have to choose which one it might be.

Yes, but another forum is really not necessary here. This one is really not that busy. I can help either way.

Ted
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
izidor
Veteran
Posts: 110
Joined: Wed Apr 22, 2009 3:13 am
Contact:

Post by izidor »

I checked the values and if I'm right that part is good. Thanks for advice.
Post Reply