BoulderDash-Clone -->steine fallen zu schnell
Übersicht

TanatosBetreff: BoulderDash-Clone -->steine fallen zu schnell |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
ich habe hier ein testprogramm für einen boulderdash-clone. der code funktioniert bisher auch recht gut, nur leider fallen die steine sofort bis ganz nach unten. ein kleiner zeitpuffer zwischen den einzelnen tilesprüngen der felsen wäre nicht schlecht, nur leider bekomme ich es nicht hin. mit "delay" hat es nicht zufriedenstellend funktioniert. könnt ihr mir vielleicht auf die sprünge helfen?
Code: [AUSKLAPPEN] Const XMAX=640
Const YMAX=480 Const ESC=1 Const AUF=200 Const AB=208 Const LINKS=203 Const RECHTS=205 Const TILESIZE=20 Global posx=4 Global posy=4 Dim map(19,19) Restore level1 For y=0 To 19 For x=0 To 19 Read map(x,y) Next Next ;----------GRAPHIK LADEN------------- Graphics XMAX,YMAX,0,2 SetBuffer BackBuffer() ;----------HAUPTSCHLEIFE------------- Repeat drawmap() moveplayer() updatemap() Flip Cls Until KeyHit(ESC) End ;--------FUNKTIONEN------------------ Function moveplayer() If KeyHit(AUF) And map(posx,posy-1)<5 Then posy =posy - 1 EndIf If KeyHit(AB) And map(posx,posy+1)<5 Then posy =posy + 1 EndIf If KeyHit(LINKS) And map(posx-1,posy)<5 Then posx =posx - 1 EndIf If KeyHit(RECHTS) And map(posx+1,posy)<5 Then posx =posx + 1 EndIf Color 0,255,0 : Rect posx*TILESIZE,posy*TILESIZE,TILESIZE,TILESIZE End Function Function drawmap() For y=0 To 19 For x=0 To 19 If map(x,y)=0 Then Color 0,0,0 : Rect x*TILESIZE,y*TILESIZE,TILESIZE,TILESIZE If map(x,y)=1 Then Color 100,50,0 : Rect x*TILESIZE,y*TILESIZE,TILESIZE,TILESIZE ;If map(x,y)=2,3,4 Then Color 50,50,50 : Rect x*TILESIZE,y*TILESIZE,TILESIZE,TILESIZE ;für später If map(x,y)=5 Then Color 255,255,255 : Rect x*TILESIZE,y*TILESIZE,TILESIZE,TILESIZE If map(x,y)=6 Then Color 55,55,55 : Oval x*TILESIZE,y*TILESIZE,TILESIZE,TILESIZE Next Next End Function Function updatemap() If map(posx,posy)=1 Then map(posx,posy)=0;erde durh gang ersetzen For y=0 To 19;stein-physik For x=0 To 19 If map(x,y)=6 Then ;bewegt den stein nach unten wenn kein If map(x,y+1)=0 Then ;hindernis vorhanden ist map(x,y)=0 map(x,y+1)=6 EndIf EndIf Next Next End Function .level1 Data 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5 Data 5,1,1,1,1,1,1,1,1,1,6,1,1,1,1,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,0,1,1,1,6,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5 Data 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5 |
||
![]() |
FreetimeCoder |
![]() Antworten mit Zitat ![]() |
---|---|---|
Machs doch ungefähr so:
Code: [AUSKLAPPEN] For i=1 to 20
if Stein(i) untenfrei then If Steinzeit(i)>10 Movestein 1 Feld nach unten Steinzeit(i)= 0 else Steinzeit(i)=Steinzeit(i)+1 endif endif next Wenn unten frei ist, wird erst zu einer Variable 1 addiert. Wenn die Variable eine bestimmte Größe erreicht hat, fällt der Stein ein Feld runter und die Variable wird auf 0 gesetzt. |
||
"Wir haben keine Chance, aber wir werden sie nutzen!"
Projekte: Dexterity Ball (100%) Aquatic Atmosfear (22 % ca 4700 Zeilen) eingefrohren mangels OOP Fähigkeiten von Blitz (ehemals Uboot) PC: Intel D 3 GHz | NVidiaGforce 6700 256 Mb | 1024 Mb DDR RAM 400 Mhz | 2x160 GB S-ATA |
![]() |
BlitzcoderNewsposter |
![]() Antworten mit Zitat ![]() |
---|---|---|
Hier mal ein ganzer Code(mit Types, so kannst du so viele Steine dazutun, wie du willst)
Code: [AUSKLAPPEN] Const XMAX=640 Const YMAX=480 Const ESC=1 Const AUF=200 Const AB=208 Const LINKS=203 Const RECHTS=205 Const TILESIZE=20 Global posx=4 Global posy=4 Dim map(19,19) Type stein field y,x Field fallzeit End Type Restore level1 For y=0 To 19 For x=0 To 19 Read map(x,y) If map(x,y)=6 Then tmp.stein=new stein tmp\x=x tmp\y=y EndIf Next Next ;----------GRAPHIK LADEN------------- Graphics XMAX,YMAX,0,2 SetBuffer BackBuffer() ;----------HAUPTSCHLEIFE------------- Repeat drawmap() moveplayer() updatemap() Flip Cls Until KeyHit(ESC) End ;--------FUNKTIONEN------------------ Function moveplayer() If KeyHit(AUF) And map(posx,posy-1)<5 Then posy =posy - 1 EndIf If KeyHit(AB) And map(posx,posy+1)<5 Then posy =posy + 1 EndIf If KeyHit(LINKS) And map(posx-1,posy)<5 Then posx =posx - 1 EndIf If KeyHit(RECHTS) And map(posx+1,posy)<5 Then posx =posx + 1 EndIf Color 0,255,0 : Rect posx*TILESIZE,posy*TILESIZE,TILESIZE,TILESIZE End Function Function drawmap() For y=0 To 19 For x=0 To 19 If map(x,y)=0 Then Color 0,0,0 : Rect x*TILESIZE,y*TILESIZE,TILESIZE,TILESIZE If map(x,y)=1 Then Color 100,50,0 : Rect x*TILESIZE,y*TILESIZE,TILESIZE,TILESIZE ;If map(x,y)=2,3,4 Then Color 50,50,50 : Rect x*TILESIZE,y*TILESIZE,TILESIZE,TILESIZE ;für später If map(x,y)=5 Then Color 255,255,255 : Rect x*TILESIZE,y*TILESIZE,TILESIZE,TILESIZE If map(x,y)=6 Then Color 55,55,55 : Oval x*TILESIZE,y*TILESIZE,TILESIZE,TILESIZE Next Next End Function Function updatemap() If map(posx,posy)=1 Then map(posx,posy)=0;erde durh gang ersetzen For tmp.stein = Each stein If tmp\fallzeit<>0 Then If Not tmp\y=20 If map(tmp\x,tmp\y+1)<>0 tmp\fallzeit=0 EndIf Else tmp\fallzeit=0 EndIf EndIf If map(tmp\x,tmp\y+1) = 0 Then If tmp\fallzeit = 0 Then tmp\fallzeit=millisecs() EndIf If tmp\fallzeit<>0 Then If (MilliSecs()-tmp\fallzeit)>80 Then map(tmp\x,tmp\y) = 0 map(tmp\x,tmp\y+1) = 6 tmp\y=tmp\y+1 EndIf EndIf Next End Function .level1 Data 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5 Data 5,1,1,1,1,1,1,1,1,1,6,1,1,1,1,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,0,1,1,1,6,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5 Data 5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5 Data 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5 |
||
P4 3 Ghz@3,55Ghz|GF 6600GT 256MB|Samsung 80GB | 2x Samsung 160GB|2048MB DDR-400 RAM|6 Mbit Flatrate | Logitech G15 | Samsung 225BW-TFT | Ubuntu Gutsy Linux | Windows Vista | Desktop | Blog | CollIDE | Worklog
________________ |°°°°°°°°°°°°°°||'""|""\__,_ |______________ ||__ |__|__ |) |(@) |(@)"""**|(@)(@)****|(@) |
- Zuletzt bearbeitet von Blitzcoder am Do, Aug 31, 2006 18:35, insgesamt einmal bearbeitet
![]() |
PSY |
![]() Antworten mit Zitat ![]() |
---|---|---|
bei Bitzcoder's code müssen die letzen beiden data's raus, oder map muss (19,21) deklariert werden, ansonsten kommt ne OOB
l8er, psy |
||
![]() |
BlitzcoderNewsposter |
![]() Antworten mit Zitat ![]() |
---|---|---|
Ich hab es editiert. Ich hab die letzte data Zeile einmal verdreifacht, da es nicht funktionierte, und ich testen wollte, ob es daran liegt.
MfG Blitzcoder |
||
P4 3 Ghz@3,55Ghz|GF 6600GT 256MB|Samsung 80GB | 2x Samsung 160GB|2048MB DDR-400 RAM|6 Mbit Flatrate | Logitech G15 | Samsung 225BW-TFT | Ubuntu Gutsy Linux | Windows Vista | Desktop | Blog | CollIDE | Worklog
________________ |°°°°°°°°°°°°°°||'""|""\__,_ |______________ ||__ |__|__ |) |(@) |(@)"""**|(@)(@)****|(@) |
Tanatos |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Coole Sache ![]() vielen Dank für die Hilfe ![]() |
||
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group