Schwerkraft Problem
Übersicht

oki02Betreff: Schwerkraft Problem |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Ich versuche gerade ein Jump "n" run Spiel zu Programmieren.
Habe aber folgendes Problem: ich möchte eine Schwerkraft einbauen aber nur wie? Hab es schon probiert aber er fliegt einfach überall durch. Code: [AUSKLAPPEN] Graphics 1024,768,16,1 tileset = LoadAnimImage("tileset.bmp",32,32,0,4) char = LoadImage("char.bmp") px = 6 py = 6 move = 1 Dim map(20,20) For y = 0 To 20 For x = 0 To 20 Read map(x,y) Next Next Repeat SetBuffer BackBuffer() Cls If KeyDown(1) Then End For y = 0 To 20 For x = 0 To 20 DrawBlock tileset ,x*32,y*32,map(x,y) Next Next If KeyDown(208) Then If map(px,py+1) < 2 Then py = py +1 move = 1 EndIf EndIf If KeyDown(200) Then If map(px,py-1) < 2 Then py = py - 1 move = 1 End If End If If KeyDown(203) Then If map(px-1,py) < 2 Then px = px - 1 move = 1 End If End If If KeyDown(205) Then If map(px+1,py) < 2 Then px = px + 1 move = 1 End If End If If move = 1 Then x= px*32 y = py*32: DrawImage char,x,y py = py + 1 Flip Forever .map Data 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,2 Data 2,0,3,3,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,2 Data 2,0,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,3,3,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,3,3,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,3,3,0,0,0,0,0,0,0,0,3,3,0,0,0,0,2 Data 2,0,0,0,3,3,0,0,0,0,0,0,0,0,3,3,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 |
||
![]() |
robotx |
![]() Antworten mit Zitat ![]() |
---|---|---|
Zuerst mal SetBuffer BackBuffer () aus der Schleife rausnehmen und nach Graphics setzen. Und du solltest den Code einrücken und strukturieren, dann ist er leichter lesbar und verständlicher.
Zur Schwerkraft: Du überprüfst das Feld unter dem Spieler, ob es "Luft" ist oder ein fester Gegenstand (Boden...). Wenn es Luft ist, fällt der Spieler nach unten, ansonsten bleibt er stehen. mfg robotx |
||
www.botbomb.robotzgames.de
www.robotzgames.de |
oki02 |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Danke für die Schnelle Antwort!
Habe jetzt nur mer ein Problem und zwar: eine Sprungfunktion. Versuche hin und her aber ich bringe es leider nicht zusammen mein aktueller code: Code: [AUSKLAPPEN] Graphics 1024,768,16,1 SetBuffer BackBuffer() tileset = LoadAnimImage("tileset.bmp",32,32,0,4) char = LoadImage("char.bmp") px = 6 py = 6 move = 1 jump = False Dim map(20,20) For y = 0 To 20 For x = 0 To 20 Read map(x,y) Next Next Repeat Cls If KeyDown(1) Then End For y = 0 To 20 For x = 0 To 20 DrawBlock tileset ,x*32,y*32,map(x,y) Next Next If KeyHit(203) Then If map(px-1,py) < 2 Then px = px - 1 move = 1 End If End If If KeyHit(205) Then If map(px+1,py) < 2 Then px = px + 1 move = 1 End If End If If KeyHit(57) Then jump = True EndIf If jump = True Then py = py - 5 EndIf If move = 1 Then x= px*32 y = py*32: DrawImage char,x,y If map(px+1,py) < 2 Then If map(px-1,py) < 2 Then If map(px,py+1) < 2 Then If map(px,py-1) < 2 Then py = py + 1 EndIf EndIf EndIf EndIf Flip Forever .map Data 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,2 Data 2,0,3,3,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,2 Data 2,0,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,3,3,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,3,3,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,3,3,0,0,0,0,0,0,0,0,3,3,0,0,0,0,2 Data 2,0,0,0,3,3,0,0,0,0,0,0,0,0,3,3,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 hoffentlich könnt ihr mir helfen. Schon mal Danke im Voraus mfg Oki02 |
||
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group