Freilaufen auf Tiles inkl. Kollisionen :/
Übersicht

![]() |
klinBetreff: Freilaufen auf Tiles inkl. Kollisionen :/ |
![]() Antworten mit Zitat ![]() |
---|---|---|
Hallo Leute,
ich habe ein Problem, das mich fast schon ein ganzes Jahr verfolgt >.< Undzwar, will ich ein 2D Game machen, wo man frei rumlaufen kann, doch natürlich mit Mauern (Kollisionen). Von tile zu tile, war kein Problem, doch nun von pixel zu pixel (also freirumlaufen) ist schon ein Problem. Das war zumindest das letzte was ich gemacht hatt ![]() Code: [AUSKLAPPEN] 'Collisions-zwischen-Test Graphics 640,480 Global map[24,25] Global spawnpointx:Float[24] Global spawnpointy:Float[25] 'tilemapdaten 23x24 #map DefData 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 DefData 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 DefData 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 DefData 1,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1 DefData 1,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1 DefData 1,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1 DefData 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 DefData 1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 DefData 1,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,1 DefData 1,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,1 DefData 1,0,0,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,1 DefData 1,0,0,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,1 DefData 1,0,0,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,1 DefData 1,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 DefData 1,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 DefData 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 DefData 1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1 DefData 1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1 DefData 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 DefData 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 DefData 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 DefData 1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,1 DefData 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 DefData 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 'Tiles lesen RestoreData map For Local j=0 To 23 For Local i=0 To 22 ReadData map[i,j] Next Next For j=0 To 24 For i=0 To 23 If map[i,j]=1 Then SetColor 255,0,0 DrawRect 20*i,20*j,20,20 SetColor 255,255,255 ElseIf map[i,j]=2 Then SetColor 0,0,255 spawnpointx[1]=i spawnpointy[1]=j DrawRect 20*i,20*j,20,20 SetColor 255,255,255 EndIf Next Next While Not AppTerminate() For j=0 To 24 For i=0 To 23 If map[i,j]=1 Then SetColor 255,0,0 DrawRect 20*i,20*j,20,20 SetColor 255,255,255 Rem ElseIf map[i,j]=2 Then SetColor 0,0,255 spawnpointx[1]=i spawnpointy[1]=j DrawRect 20*i,20*j,20,20 SetColor 255,255,255 EndRem EndIf Next Next If KeyDown(KEY_UP) Then If map[spawnpointx[1],spawnpointy[1]]<>1 Then spawnpointy[1]=spawnpointy[1]-0.1 EndIf EndIf If KeyDown(KEY_DOWN) Then If map[spawnpointx[1],spawnpointy[1]+1]<>1 Then spawnpointy[1]=spawnpointy[1]+0.1 EndIf EndIf If KeyDown(KEY_RIGHT) Then If map[spawnpointx[1]+1,spawnpointy[1]]<>1 Then spawnpointx[1]=spawnpointx[1]+0.1 EndIf EndIf If KeyDown(KEY_LEFT) Then If map[spawnpointx[1],spawnpointy[1]+1]<>1 Then spawnpointx[1]=spawnpointx[1]-0.1 EndIf EndIf DrawOval 20*spawnpointx[1],20*spawnpointy[1],20,20 DrawText Int(spawnpointx[1])+" | "+Int(spawnpointy[1]),0,0 Flip Cls Wend End so weit bin ich gekommen... danach verlor ich die Lust und regte mich nurnoch auf, weil die blöden kollisionen nicht funktionieren ![]() Also seit ihr meine letzte hoffnung! Ich wäre euch sehr dankbar! THX MFG Klin |
||
![]() |
Markus2 |
![]() Antworten mit Zitat ![]() |
---|---|---|
Guck dir mal an:
ImagesCollide ImagesCollide2 ResetCollisions CollideImage CollideRect ein Beispiel findest du auch dabei |
||
battlegorge |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Sowas hatte ich letztes Jahr mal ins Codearchiv gestellt:
https://www.blitzforum.de/foru...hp?t=25173 Ist aber nicht ganz ausgereift. Man muss eigentlich nur die 9 Tiles um den Spieler auf Kollisionen überprüfen. Wenn über dem Spieler eine Kollision ist bewegt er sich nicht hoch usw. |
||
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group