Jump`n`run Collision.... Wie geht das ?

Übersicht BlitzBasic Beginners-Corner

Neue Antwort erstellen

ToeB

Betreff: Jump`n`run Collision.... Wie geht das ?

BeitragSo, Dez 02, 2007 14:54
Antworten mit Zitat
Benutzer-Profile anzeigen
Code: [AUSKLAPPEN]
Graphics 800,600,16,1
SetBuffer BackBuffer()
AppTitle "Oval Fighters"

Type s
Field x,y,w#,s#,del
End Type

Dim OF(180)
Dim W(180)
Dim Map(31,23)
Global s.s
Global x=400,y#=300,Jump,fy#,winkel#,RI,Waffe
Global OF_img = LoadAnimImage("gfx\OF.bmp",35,35,0,2):MidHandle OF_img
Global WA = LoadAnimImage("gfx\W1.bmp",35,65,0,4):MidHandle WA
Global Pointer = LoadAnimImage("gfx\Pointer.bmp",25,25,0,2):MidHandle Pointer
Global TileSet = LoadAnimImage("gfx\TileSet.bmp",25,25,0,2):MaskImage TileSet,255,0,255

For yy = 0 To 23
For xx = 0 To 31
Read map(xx,yy)
Next
Next

TFormFilter 2
For i = 0 To 180
Cls
OF(i) = CopyImage(OF_img)
 W(i) = CopyImage(WA    )
RotateImage OF(i),i*2
RotateImage  W(i),i*2
Text 1,1,"Lade Bild "+i
Flip
Next

Repeat
ox = x:oy = y
winkel = -ATan2(MouseX()-x,MouseY()-y)+180
If winkel < 0 Then winkel = 360
If winkel > 360 Then winkel = 0
If winkel => 0 And winkel < 180 Then RI = 0
If winkel => 180 And winkel < 360 Then RI = 1
If KeyDown(30) Then x = x - 1
If KeyDown(32) Then x = x + 1
If KeyHit(17) And Jump = 0 Then Jump = 1:fy = 5
If Jump = 1 Then
fy = fy - 0.1
y = y - fy
Else
;fy = fy + 0.1
;y = y + fy
EndIf
If MouseHit(1) Then
s.s = New s
s\x = x;+Cos(winkel-90)*17.5
s\y = y;+Sin(winkel-90)*32.5
s\w = winkel-90
s\s = 5
EndIf
For i = 2 To 3
If KeyHit(i) Then Waffe = i-2
Next
For xx = 0 To 31
For yy = 0 To 23
If map(xx,yy) > 0 Then
DrawImage TileSet,xx*25,yy*25,map(xx,yy)
If ImageRectCollide(OF(winkel/2),x,y,RI,xx*25,yy*25,25,25) Then x = ox:y = oy:Jump = 0
EndIf
Next
Next
For s.s = Each s
s\x = s\x + Cos(s\w) * s\s
s\y = s\y + Sin(s\w) * s\s
Oval s\x-5,s\y-5,10,10
If s\x-5 < 0 Or s\x+5 > 800 Or s\y-5 < 0 Or s\y+5 > 600 Then s\Del = 1
If s\Del = 1 Delete s.s
Next
DrawImage OF(winkel/2),x,y,RI
DrawImage W(winkel/2),x,y,Waffe*2+RI
DrawImage Pointer,MouseX(),MouseY()
Text 1,1,"Winkel : "+winkel
Flip
Cls
Until KeyHit(1)
End


.Map1
Data 0,0,0,0,0,0,0,0,0,0,0,0,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,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,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,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,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,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,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,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,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,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,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,1,1,1,1,1,1,0,0,0,0,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,1,0,0,0,0,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,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 1,1,1,1,1,0,0,1,0,0,0,0,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,1,0,0,0,0,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,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,1,1,1,1,1,1,0,0,0,0,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,1,0,0,0,0,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,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 1,1,1,1,1,0,0,1,0,0,0,0,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,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,0,0,0,0,0,0,0,0,0,0,0,0
Data 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1


Wie krig ich das hin, das mit der Collision auf Jump`n`run Ebene ? Also wenn ich von unten Drann springe, dass ich trotzdem noch nach Links und Rechts laufen kann, oder wenn ich gegen eine Wand laufe, dass ich trotydem noch springen kann.... K;nnt ihr mir da weiter helfen ?

thx und mfg cRacK93

~EDIT~

user posted image

Hier ein Bild, damit ihr mal seht wie das ungef'r aussieht.....

mfg cRacK93

ToeB

BeitragSo, Dez 02, 2007 16:24
Antworten mit Zitat
Benutzer-Profile anzeigen
Sorry for Doppel-post, da mir keiner antwortet und ich ne neue Frage habe...

Code: [AUSKLAPPEN]
Graphics 800,600,16,2
SetBuffer BackBuffer()
AppTitle "Oval Fighters"

Type s
Field x,y,w#,s#,del,Typ
End Type

Dim OF(180)
Dim W(180)
Dim Map(31,23)
Global s.s
Global x=400,y#=300,Jump,fy#,winkel#,RI,Waffe
Global OF_img = LoadAnimImage("gfx\OF.bmp",35,35,0,2):MidHandle OF_img
Global WA = LoadAnimImage("gfx\W1.bmp",35,65,0,4):MidHandle WA
Global Pointer = LoadAnimImage("gfx\Pointer.bmp",25,25,0,2):MidHandle Pointer
Global TileSet = LoadAnimImage("gfx\TileSet.bmp",25,25,0,2):MaskImage TileSet,255,0,255

For yy = 0 To 23
For xx = 0 To 31
Read map(xx,yy)
Next
Next

TFormFilter 2
Print "Lade Grafiken ...."
Flip
For i = 0 To 180
OF(i) = CopyImage(OF_img)
 W(i) = CopyImage(WA    )
RotateImage OF(i),i*2
RotateImage  W(i),i*2
;Text 1,1,"Lade Bild "+i
;Text 105,1,String(".",i Mod 11)
;Flip
Next
Print "Fertig !"
Flip
Delay 1000
Repeat
ox = x:oy = y
winkel = -ATan2(MouseX()-x,MouseY()-y)+180
If winkel < 0 Then winkel = 360
If winkel > 360 Then winkel = 0
If winkel => 0 And winkel < 180 Then RI = 0
If winkel => 180 And winkel < 360 Then RI = 1
If KeyDown(30) Then x = x - 1
If KeyDown(32) Then x = x + 1
If KeyHit(17) And Jump = 0 Then Jump = 1:fy = 5
If Jump = 1 Then
fy = fy - 0.1
y = y - fy
Else
fy = fy + 0.1
y = y + fy
EndIf
Select Waffe
Case 0
If MouseHit(1) Then
s.s = New s
s\x = x;+Cos(winkel-90)*17.5
s\y = y;+Sin(winkel-90)*32.5
s\w = winkel-90
s\s = 5
s\Typ = 0
EndIf
Case 1
If MouseDown(1) Then
s.s = New s
s\x = x;+Cos(winkel-90)*17.5
s\y = y;+Sin(winkel-90)*32.5
s\w = winkel-90+Rnd(-2,2)
s\s = 5+Rnd(-1.0,1.0)
s\Typ = 1
EndIf
End Select
For i = 2 To 3
If KeyHit(i) Then Waffe = i-2
Next
For xx = 0 To 31
For yy = 0 To 23
If map(xx,yy) > 0 Then
DrawImage TileSet,xx*25,yy*25,map(xx,yy)
If RectsOverlap(x-15,y-18,32.5,1,xx*25,yy*25,25,25) Then x = ox
If RectsOverlap(x-15,y+18,32.5,1,xx*25,yy*25,25,25) Then x = ox
If RectsOverlap(x-18,y-15,1,32.5,xx*25,yy*25,25,25) Then y = oy:Jump = 0:fy = 0
If RectsOverlap(x+18,y-15,1,32.5,xx*25,yy*25,25,25) Then Jump = 0:fy = 0
EndIf
Next
Next
For s.s = Each s
s\x = s\x + Cos(s\w) * s\s
s\y = s\y + Sin(s\w) * s\s
If s\Typ = 0
Oval s\x-5,s\y-5,10,10
ElseIf s\Typ = 1
Plot s\x,s\y
EndIf
If s\x < -10 Or s\x > 810 Or s\y < -10 Or s\y > 610 Then s\Del = 1
If s\Del = 1 Delete s.s
Next
DrawImage OF(winkel/2),x,y,RI
DrawImage W(winkel/2),x,y,Waffe*2+RI
DrawImage Pointer,MouseX(),MouseY()
Rect x-15,y-18,32.5,1
Rect x-15,y+18,32.5,1
Rect x-18,y-15,1,32.5
Rect x+18,y-15,1,32.5
Text 1,1,"Winkel : "+winkel
Flip
Cls
Until KeyHit(1)
End


.Map1
Data 0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0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0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,1,0,0,0,0,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,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 1,1,1,1,1,0,0,1,0,0,0,0,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,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,0,0,0,0,0,0,0,0,0,0,0,0
Data 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1


Ich hab mal im Forum gesucht und was gefunden. Ich hab das jetzt mit Balken gamacht, so kann ich prufen, aus welcher richtung die Collision kommt. Aber iwie funzt dat net Exclamation Question

Konnt ihr mir helfen Question

thx und mfg cRacK93

~EDIT~

Ich wei- jetyt wo der Fehler lag... Funzt prima Very Happy

mfg Crack93
Religiöse Kriege sind Streitigkeiten erwachsener Männer darum, wer den besten imaginären Freund hat.
Race-Project - Das Rennspiel der etwas anderen Art
SimpleUDP3.0 - Neuste Version der Netzwerk-Bibliothek
Vielen Dank an dieser Stelle nochmal an Pummelie, welcher mir einen Teil seines VServers für das Betreiben meines Masterservers zur verfügung stellt!

The_Nici

BeitragSo, Dez 02, 2007 20:48
Antworten mit Zitat
Benutzer-Profile anzeigen
Würde eh die Kollisionen von DerHase nehmen.

Suchwörter:
Tilemapscrolling
Autor:
DerHase
Forum:
Codearchiv (BlitzBasic)
 

HyDr0x

BeitragSo, Dez 02, 2007 20:58
Antworten mit Zitat
Benutzer-Profile anzeigen
Ka ob du das jetzt extra wegen uns so gemacht hast, wenn nicht würde ich dir nen Mapeditor für die Karten empfehlen. Denn das ewige Data schreiben ist ziemlich lästig.

Neue Antwort erstellen


Übersicht BlitzBasic Beginners-Corner

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group