Problem mit einer Tilemap

Übersicht BlitzBasic Beginners-Corner

Neue Antwort erstellen

nX^

Betreff: Problem mit einer Tilemap

BeitragSa, März 12, 2005 22:47
Antworten mit Zitat
Benutzer-Profile anzeigen
also ich mache zurweit ein kleines pacman game
udn ich hab folgendes Problem: wenn ich ne tste drücke dann wir die figur links oben inna ecke gezeichnet............
Bitte helft mal
Code: [AUSKLAPPEN]
Graphics 1024,768,16,1

tileset = LoadAnimImage("gfx\tileset.bmp",32,32,0,6)

char = LoadImage("gfx\pacman_normal.bmp")
char_oben = LoadImage("gfx\pacman_oben.bmp")
char_rechts = LoadImage("gfx\pacman_rechts.bmp")
char_unten = LoadImage("gfx\pacman_unten.bmp")
char_links = LoadImage("gfx\pacman_links.bmp")


px = 6

py = 6

move = 1


Dim map(20,20)


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,1,2,3,4,5,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


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
DrawImage char_unten,x,y
If map(px,py+1) < 2 Then
py = py + 1
move = 1
End If
End If

If KeyDown(200) Then
DrawImage char_oben,x,y
If map(px,py-1) < 2 Then
py = py - 1
move = 1
End If
End If

If KeyDown(203) Then
DrawImage char_links,x,y
If map(px-1,py) < 2 Then
px = px - 1
move = 1
End If
End If

If KeyDown(205) Then
DrawImage char_rechts,x,y
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

Flip
Forever

Sir Dan

BeitragSo, März 13, 2005 8:32
Antworten mit Zitat
Benutzer-Profile anzeigen
x und y bleiben in deinem Code immer gleich

probiere es mal mit py und px
Code: [AUSKLAPPEN]
DrawImage char_unten,px,py

und mach nach dem repeat Code: [AUSKLAPPEN]
 move = 0

sonst läuft der immer weiterCode: [AUSKLAPPEN]
(\_/)
(O.o)
(> <) This is Bunny. Copy Bunny into your signature to help him on his way to world domination.

DA

BeitragSo, März 13, 2005 12:29
Antworten mit Zitat
Benutzer-Profile anzeigen
Moin,

Und bitte kein Setbuffer in der Schleife!
Einmal vor der Schleife reicht volkommen!
Außerdem brauchst du nicht nach jedem Tastendruck das Bild zeichnen. Zeichne es doch einfach kurz vor dem Ende der Schleife.

Thx
DarkAngel
Deutscher Blitz Basic Chat

nX^

BeitragSo, März 13, 2005 14:52
Antworten mit Zitat
Benutzer-Profile anzeigen
danke
hat mich schon ein stück weitergebracht....
nur der lässt den char verschwinden und er ist imma noch oben links inna ecke.....
er soll auch wenn er jetzt zb nach rechts geht soll pacman_rechts gezeichnet werden und dannach sofort pacman_normal, dann wieder rechts.....
also das eine animation entsteht

nX^

BeitragSo, März 13, 2005 17:10
Antworten mit Zitat
Benutzer-Profile anzeigen
bitte helft mir

simi

BeitragSo, März 13, 2005 20:00
Antworten mit Zitat
Benutzer-Profile anzeigen
Ok, du willst also einen übergang.....

nehmen wir an x ist charposition px ist die Feldnummer, in dem sich der Char befindet.....

du veränderts jetzt immer px, also musst du nur noch machen dass px*32 = x ist....:
Code: [AUSKLAPPEN]

if (px*32<>x) or (py*32<>y) then
  if x < px*32 then x=x+2
  if x > px*32 then x=x-2
  if y < py*32 then y=y+2
  if y > py*32 then y=y-2
else
  move = 0
end if


So, jetzt sollte die Figur noch in die richtige Richtung schauen, für das verwendest du die Variable move: Ist move 0, dann steht die Figur, 1 ist recht, 2 ist unten .....
Code: [AUSKLAPPEN]

if move = 0 then DrawImage Figur_normal,x,y
if move = 1 then DrawImage Figur_rechts;.......


cu simi

nX^

BeitragSo, März 13, 2005 20:24
Antworten mit Zitat
Benutzer-Profile anzeigen
geht imma noch net

simi

BeitragSo, März 13, 2005 20:25
Antworten mit Zitat
Benutzer-Profile anzeigen
Was genau geht nicht? Wie sieht der Code aus?? Ein bisschen mehr Infos wären wirklich nicht schlecht.... Rolling Eyes

nX^

BeitragSo, März 13, 2005 20:55
Antworten mit Zitat
Benutzer-Profile anzeigen
Das is der ich hab ihn zurück gesettzt weil es garnet mehr ging
poste doch bitte den kopletten code mit der veränderung.........
BlitzBasic: [AUSKLAPPEN]
Graphics 1024,768,16,1 

tileset = LoadAnimImage(\"gfx\tileset.bmp\",32,32,0,6)

char = LoadImage(\"gfx\pacman_normal.bmp\")
char_oben = LoadImage(\"gfx\pacman_oben.bmp\")
char_rechts = LoadImage(\"gfx\pacman_rechts.bmp\")
char_unten = LoadImage(\"gfx\pacman_unten.bmp\")
char_links = LoadImage(\"gfx\pacman_links.bmp\")


px = 6

py = 6

move = 1


Dim map(20,20)


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,1,2,3,4,5,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


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
DrawImage char_unten,x,y
If map(px,py+1) < 2 Then
py = py + 1
move = 1
End If
End If

If KeyDown(200) Then
DrawImage char_oben,x,y
If map(px,py-1) < 2 Then
py = py - 1
move = 1
End If
End If

If KeyDown(203) Then
DrawImage char_links,x,y
If map(px-1,py) < 2 Then
px = px - 1
move = 1
End If
End If

If KeyDown(205) Then
DrawImage char_rechts,x,y
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

Flip
Forever

simi

BeitragSo, März 13, 2005 21:02
Antworten mit Zitat
Benutzer-Profile anzeigen
nex hat Folgendes geschrieben:

poste doch bitte den kopletten code mit der veränderung.........


Du willst programmieren, nicht ich.....

Versuchs doch mal umzusetzten, und wenn du nicht weitekommst, Können wir dir helfen!!!

nX^

BeitragSo, März 13, 2005 21:12
Antworten mit Zitat
Benutzer-Profile anzeigen
ich komme ja nicht weiter das ist das problem....

Neue Antwort erstellen


Übersicht BlitzBasic Beginners-Corner

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group