Probleme mit Jump'n'Run Tile-engine
Übersicht

![]() |
PaulBetreff: Probleme mit Jump'n'Run Tile-engine |
![]() Antworten mit Zitat ![]() |
---|---|---|
Tag zusammen,
Ich habe folgendes problem: Ich zeichne meine map so: Code: [AUSKLAPPEN] Function DrawMap()
For y = 0 To 14 For x = 0 To 19 If map(x,y) = 1 Then DrawImage tiles, x*32-offsetx, y*32-offsety, 0 If map(x,y) = 2 Then DrawImage tiles, x*32-offsetx, y*32-offsety, 1 If map(x,y) = 3 Then DrawImage tiles, x*32-offsetx, y*32-offsety, 2 If map(x,y) = 4 Then DrawImage tiles, x*32-offsetx, y*32-offsety, 3 Next Next End Function bewege meine figur so: Code: [AUSKLAPPEN] Function movehero()
If KeyDown(200) Then If map((herox+16)/32,heroy/32) = mapfree Then heroy=heroy-3 If heroy<0 Then heroy=0 EndIf EndIf If KeyDown(208) Then If map((herox+16)/32,(heroy+32)/32) = mapfree Then heroy=heroy+3 If heroy>480 Then heroy=0 EndIf EndIf If KeyDown(205) Then If map((herox+32)/32,(heroy+16)/32) = mapfree Then herox=herox+3 If herox>640 Then herox=0 EndIf EndIf If KeyDown(203) Then If map((herox)/32,(heroy+16)/32) = mapfree Then herox=herox-3 If herox<0 Then herox=0 EndIf EndIf End Function wobei die variable mapfree 0 ist jetzt brauch ich natürlich für ein jump'n'run eine art offset-function das hab ich so: Code: [AUSKLAPPEN] Function offset()
If herox>offsetx+200 Then offsetx=offsetx+3 End Function ich will, dass sich die Figur in einem bestimmten Rahmen in der Bildschirmmitte bewegen kann und sich der Bildausschnitt erst bewegt, wenn dieser Rahmen übertreten wird. (wirkt viel eleganter 8) ) nur stimmt die offset-sache bei mir nicht so. der level bewegt sich nicht im richtigen tempo. ist schwer zu beschreiben, deshalb hab ich hier quelltext+grafiken: www.8ung.at/pa-may/jump.zip (nur 1.5 KB) zum selber ausprobieren. Wär super, wenn mir jemand helfen könnte! Paul |
||
Stratocaster black - Roland MicroCube
User posted image Girgl-World, wer's nich kennt, is' blöd! |
![]() |
TheShadowModerator |
![]() Antworten mit Zitat ![]() |
---|---|---|
bitte optimieren
If map(x,y) = 1 Then DrawImage tiles, x*32-offsetx, y*32-offsety, 0 If map(x,y) = 2 Then DrawImage tiles, x*32-offsetx, y*32-offsety, 1 If map(x,y) = 3 Then DrawImage tiles, x*32-offsetx, y*32-offsety, 2 If map(x,y) = 4 Then DrawImage tiles, x*32-offsetx, y*32-offsety, 3 |
||
AMD64 3500+ | GeForce6600GT 128MB | 1GB DDR | WinXPsp2 |
![]() |
Kryan |
![]() Antworten mit Zitat ![]() |
---|---|---|
Code: [AUSKLAPPEN] Graphics 640,480,16 SetBuffer BackBuffer() Global tiles = LoadAnimImage ("gfx/tiles.bmp",32,32,0,20) Global hero = LoadImage("gfx/hero.bmp") Global herox=0 Global heroy=200 Global offsetx=0 Global offsety=0 Global level1=1 Global level2=0 Global mapfree=0 Dim map (20,15) If level1=1 Then Restore mapdata1 For y=0 To 14 For x=0 To 19 Read map(x,y) Next Next ClsColor 0, 0, 255 timer = CreateTimer (40) While KeyHit(1)=0 Cls DrawMap() movehero() offset() DrawImage hero,herox,heroy Text 0,0,"herox= "+herox Text 0,20,"heroy= "+heroy Text 0,40,"offsetx= "+offsetx Text 0,60,"offsety= "+offsety WaitTimer (timer) Flip Wend End Function DrawMap() For y = 0 To 14 For x = 0 To 19 If map(x,y) = 1 Then DrawImage tiles, x*32-offsetx, y*32-offsety, 0 If map(x,y) = 2 Then DrawImage tiles, x*32-offsetx, y*32-offsety, 1 If map(x,y) = 3 Then DrawImage tiles, x*32-offsetx, y*32-offsety, 2 If map(x,y) = 4 Then DrawImage tiles, x*32-offsetx, y*32-offsety, 3 Next Next End Function Function movehero() If KeyDown(200) Then If map((herox+16)/32,heroy/32) = mapfree Then heroy=heroy-3 If heroy<0 Then heroy=0 EndIf EndIf If KeyDown(208) Then If map((herox+16)/32,(heroy+32)/32) = mapfree Then heroy=heroy+3 If heroy>480 Then heroy=0 EndIf EndIf If KeyDown(205) Then If map((herox+32)/32,(heroy+16)/32) = mapfree Then herox=herox+3 If herox>640 Then herox=0 EndIf EndIf If KeyDown(203) Then If map((herox)/32,(heroy+16)/32) = mapfree Then herox=herox-3 If herox<0 Then herox=0 EndIf EndIf End Function Function offset() If herox-offsetx>500 Then offsetx=offsetx+3 If herox-offsetx<200 Then offsetx=offsetx-3 End Function .mapdata1 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,1,2,2,2,2,2,3,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,1,2,2,2,3,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Einfach herox-offsetx nehmen und dann gucken, ob es größer als 500 oder kleiner als 200 ist und schon ist es gelöst (hoffe ich jedenfalls) |
||
Webspaceanbieter?
Klick hier! Kultige Spieleschmiede? Klick hier! |
![]() |
Paul |
![]() Antworten mit Zitat ![]() |
---|---|---|
@ TheShadow: so hab ichs doch geschrieben ![]() @Kryan: Werd ich gleich mal ausprobieren! kuck mal PN Hat jemand noch ideen für kollisionen mit offset? bischer hab ich sie halt hero-basierend gemacht. Paul |
||
Stratocaster black - Roland MicroCube
User posted image Girgl-World, wer's nich kennt, is' blöd! |
![]() |
Shadow of the night |
![]() Antworten mit Zitat ![]() |
---|---|---|
Das von Kryan hat irgendwie nen Fehler drin aber ich hab keine Zeit zu suchen.
MfG Shadow of the Night |
||
User posted image |
![]() |
Kryan |
![]() Antworten mit Zitat ![]() |
---|---|---|
Code: [AUSKLAPPEN] Graphics 640,480,16 SetBuffer BackBuffer() Global tiles = LoadAnimImage ("gfx/tiles.bmp",32,32,0,20) Global hero = LoadImage("gfx/hero.bmp") Global herox=200 Global heroy=200 Global offsetx=0 Global offsety=0 Global level1=1 Global level2=0 Global mapfree=0 Dim map (20,15) If level1=1 Then Restore mapdata1 For y=0 To 14 For x=0 To 19 Read map(x,y) Next Next ClsColor 0, 0, 255 timer = CreateTimer (40) While KeyHit(1)=0 Cls DrawMap() movehero() offset() DrawImage hero,herox-offsetx,heroy-offsety Text 0,0,"herox= "+herox Text 0,20,"heroy= "+heroy Text 0,40,"offsetx= "+offsetx Text 0,60,"offsety= "+offsety WaitTimer (timer) Flip Wend End Function DrawMap() For y = 0 To 14 For x = 0 To 19 If map(x,y) = 1 Then DrawImage tiles, x*32-offsetx, y*32-offsety, 0 If map(x,y) = 2 Then DrawImage tiles, x*32-offsetx, y*32-offsety, 1 If map(x,y) = 3 Then DrawImage tiles, x*32-offsetx, y*32-offsety, 2 If map(x,y) = 4 Then DrawImage tiles, x*32-offsetx, y*32-offsety, 3 Next Next End Function Function movehero() If KeyDown(200) Then If map((herox+16)/32,heroy/32) = mapfree Then heroy=heroy-3 EndIf EndIf If KeyDown(208) Then If map((herox+16)/32,(heroy+32)/32) = mapfree Then heroy=heroy+3 EndIf EndIf If KeyDown(205) Then If map((herox+32)/32,(heroy+16)/32) = mapfree Then herox=herox+4 EndIf EndIf If KeyDown(203) Then If map((herox)/32,(heroy+16)/32) = mapfree Then herox=herox-4 EndIf EndIf End Function Function offset() If herox-offsetx>440 Then offsetx=offsetx+8 If herox-offsetx<200 Then offsetx=offsetx-8 End Function .mapdata1 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,1,2,2,2,2,2,3,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,1,2,2,2,3,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 Jetzt ist alles in Ordnung. Ruckelt nur ganz bischen beim scrollen |
||
Webspaceanbieter?
Klick hier! Kultige Spieleschmiede? Klick hier! |
![]() |
Ctuchik |
![]() Antworten mit Zitat ![]() |
---|---|---|
Mein Tipp gegen das ruckeln:
Code: [AUSKLAPPEN] Function offset() If herox-offsetx>440 Then offsetx=herox-440 If herox-offsetx<200 Then offsetx=herox-200 End Function mfG Ctuchik |
||
![]() |
Paul |
![]() Antworten mit Zitat ![]() |
---|---|---|
Okay, dankeschön habs jetzt!!
![]() Paul |
||
Stratocaster black - Roland MicroCube
User posted image Girgl-World, wer's nich kennt, is' blöd! |
![]() |
Alfadur |
![]() Antworten mit Zitat ![]() |
---|---|---|
und was theshadow meinte :
Code: [AUSKLAPPEN] Function DrawMap() For y = 0 To 14 For x = 0 To 19 DrawImage tiles, x*32-offsetx, y*32-offsety, map(x,y)-1 Next Next End Function |
||
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group