Quote from: Moru on 2009-Jun-22
So sorry, must have forgotten to include it on the last update. Now the file contains a zip of the source too.
... Really sorry but I can't find it again.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts MenuQuote from: Moru on 2009-Jun-22
So sorry, must have forgotten to include it on the last update. Now the file contains a zip of the source too.
Quote from: Moru on 2009-Jun-22
My game Worm has a similar way of loading and displaying 2D maps, download and look at the source code and you can see how it's done. Some commands might need adjusting since GL Basic has changed a lot since then though.
http://gamecorner.110mb.com
SETSCREEN 640,480,0
level_state=0
TYPE player
x;y
vspeed
ENDTYPE
GLOBAL pl[] AS player
TYPE blocco
x;y
ENDTYPE
GLOBAL bl[] AS blocco
WHILE KEY(1)=FALSE
IF level_state=0
LOCAL b AS blocco
b.x=0
b.y=240
DIMPUSH bl[],b
LOCAL b2 AS blocco
b2.x=32
b2.y=400
DIMPUSH bl[],b2
LOCAL p AS player
p.x=0
p.y=120
p.vspeed=0
DIMPUSH pl[],p
level_state=1
ENDIF
IF level_state=1
update_player()
ENDIF
SHOWSCREEN
WEND
END
FUNCTION update_player:
FOREACH b IN bl[]
FOREACH p IN pl[]
IF collision_block(p.x,p.y,p.vspeed,b.x,b.y)=0
p.vspeed=5
ELSE
p.vspeed=0
ENDIF
p.y=p.y+p.vspeed
IF KEY(203)
p.x=p.x-3
ENDIF
IF KEY(205)
p.x=p.x+3
ENDIF
DRAWRECT p.x,p.y,32,32,RGB(255,0,0)
NEXT
DRAWRECT b.x,b.y,32,32,RGB(255,255,255)
NEXT
ENDFUNCTION
FUNCTION collision_block: xa, ya, vspeeda, xb, yb
IF(xa>=xb AND xa<=xb+32 AND ya+35+vspeeda>=yb AND ya+vspeeda<=yb+33)
RETURN 1
ELSE
RETURN 0
ENDIF
ENDFUNCTION
TYPE player
x,y
vspeed
ENDTYPE
TYPE player
x
y
vspeed
ENDTYPE
if declared=0
LOCAL time
LOCAL score
...
declared=1
ENDIF
so now the variables are declared only 1 time... thanks for the help, the single step mode helped a lot! i feel so stupid now ... thanks again, bye!
if key(enter) and press=0
phase=2
press=1
ENDIF
so when i press enter the mini-game should start, and should go on without holding the key down... and it shouldn't return to the instructions, right? i don't know why, it doesn't work... it's like the variables assume the value 0 in every new IF block, even if the are delared outside the IF blocks...
LOCAL time
LOCAL score
IF phase=0
time=2000
score=0
phase=1
ENDIF
IF phase=1
//show instructions
if key(enter)
phase=2
ENDIF
ENDIF
IF phase=2
time=time-1
//code for the game
ENDIF
what's wrong this time?