Tilemap Problem
Übersicht

![]() |
JulzBetreff: Tilemap Problem |
![]() Antworten mit Zitat ![]() |
---|---|---|
Hallo hab mal wieder ein problem:
Kann das sein das eine Tilemap 20,10 nicht richtig funktioniert sondern nur wenn x sowie y gleich sind also z.B. 10,10. Denn wenn ich jetzt da en weg rein machen will...... 1 = Wiese 2 = Weg data 1,1,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 .....dann klappt das nicht in der mitte versetzt der weg sich eins nach rechts oder links und wenn ich noch mehr einfüge dann verzieht sich die karte irgendwie, ist total komisch ![]() |
||
![]() |
BladeRunnerModerator |
![]() Antworten mit Zitat ![]() |
---|---|---|
Meine vermutung wäre dass du die Falsche Anzahl an elementen einliest und es deshalb zu Verschiebungen kommt- zeig mal deinen Code... | ||
Zu Diensten, Bürger.
Intel T2300, 2.5GB DDR 533, Mobility Radeon X1600 Win XP Home SP3 Intel T8400, 4GB DDR3, Nvidia GF9700M GTS Win 7/64 B3D BMax MaxGUI Stolzer Gewinner des BAC#48, #52 & #92 |
OJay |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
ich tippe mal ganz scharf auf eine for-schleife folgender art:
Code: [AUSKLAPPEN] for i=0 to 10
![]() das kann natürlich nicht gehen, weil hier 11 durchläufe stattfinden... also entweder so: Code: [AUSKLAPPEN] for i=0 to 9 oder so:
Code: [AUSKLAPPEN] for i=1 to 10
|
||
![]() |
Julz |
![]() Antworten mit Zitat ![]() |
---|---|---|
Warte hier mein code:
Code: [AUSKLAPPEN] ; Um die Karte einzulesen for xmap = 0 to 19 for ymap = 0 to 9 read level(xmap,ymap) next next Code: [AUSKLAPPEN] ;Um die Karte zu zeichnen for xmap = 0 to 19 for ymap = 0 to 9 drawimage map,xmap*32,ymap*32,level(xmap,ymap) next next Ich hab keine ahnung an was das liegen kann der komplette code ist ziemlich lang ich hoffe mein fehler liegt schon in dem kleinen stück hier wenn nicht dann poste ich noch mal den kompletten code |
||
stepuh |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
du hast xmap und ymap vertauscht, wenn ich mich nciht irre | ||
![]() |
Julz |
![]() Antworten mit Zitat ![]() |
---|---|---|
In wie fern vertauscht, aber ich glaub du hast recht denn in meinem ersten text ganz oben da ist ja meine tilemap (10,20) aber im spiel wird die dann genau um 90 Grad gedreht angezeigt (20,10), ich denke das hat was damit zu tun oder ??? | ||
stepuh |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
ja hat was damit zu tun!!
Code: [AUSKLAPPEN] ; Um die Karte einzulesen
for xmap = 0 to 9 for ymap = 0 to 19 read level(xmap,ymap) next next ;Um die Karte zu zeichnen for xmap = 0 to 9 for ymap = 0 to 19 drawimage map,xmap*32,ymap*32,level(xmap,ymap) next next |
||
![]() |
RallimenSieger des 30-EUR-Wettbewerbs |
![]() Antworten mit Zitat ![]() |
---|---|---|
hi, kann es sein das du vorher schon datas stehen hast
und evtuell von dem data Block noch ein zeichen einliest, weil da ein wert zuviel steht |
||
[BB2D | BB3D | BB+]
|
![]() |
Julz |
![]() Antworten mit Zitat ![]() |
---|---|---|
Also die datas stehen in einer extra datei in der levels.bb und ganz am anfang hab ich die mit include levels.bb eingebunden sonst hab ich nirgends data's verwendet ![]() |
||
![]() |
RallimenSieger des 30-EUR-Wettbewerbs |
![]() Antworten mit Zitat ![]() |
---|---|---|
mach das mal mit restore, dann sollte das auch gehen
so muss jetzt auf Party |
||
[BB2D | BB3D | BB+]
|
![]() |
Julz |
![]() Antworten mit Zitat ![]() |
---|---|---|
Was meintest du mit restore ??? | ||
OJay |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
setze vor dein data field ein label: Code: [AUSKLAPPEN] .meinlevel
und dann vor deinen for-schleifen, die das einlesen ein: Code: [AUSKLAPPEN] data 1,24,04,0,2,3 restore meinlevel
damit setzt du den "zeiger" direkt vor das richtige datafield. wichtig, wenn man mehrere anlegt... |
||
![]() |
Julz |
![]() Antworten mit Zitat ![]() |
---|---|---|
Bei mir kommt da ne fehlermeldung:
"Undefined label 'level1'" |
||
OJay |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
code her | ||
![]() |
Julz |
![]() Antworten mit Zitat ![]() |
---|---|---|
Hier mein code:
game.bb Code: [AUSKLAPPEN] apptitle "Zombie Hunter" Graphics 640, 480, 16 SetBuffer BackBuffer() include "levels.bb" global eingabe$ = 0 Global player = LoadAnimImage("GFX/Hero1.bmp",32,32,0,72) Global map = LoadanimImage("GFX/blocks.bmp",32,32,0,7) global boom = loadimage("GFX/schuss.bmp") global enemy = loadanimimage("GFX/enemy.bmp",16,32,0,4) global damage = loadimage("GFX/damage.bmp") global energy1 = loadimage("GFX/HUD1.bmp") global energy2 = loadimage("GFX/HUD2.bmp") global mg = loadsound("Sound/mg.wav") MaskImage player, 66, 120, 0 Global x = 200 Global y = 200 Global z = 1 global movex = 1 global movey = 1 Global oben = 200 Global unten = 208 Global links = 203 Global rechts = 205 Global strg = 157 Global frame = 1 Global xmap = 0 Global ymap = 0 Global counter = 2 Global Bewegung global shoot = 0 global shoot2 = 0 global monstermove = 0 global zg = 0 global schusscounter = 0 global punkte = 0 global life = 100 global bremse = millisecs() Dim level(10,20) dim monster(6,3) dim schuss(3,40,2) for xmap = 0 to 19 for ymap = 0 to 9 read level(xmap,ymap) next next Repeat Cls bremse = millisecs() drawlevel() moveplayer() drawplayer() randtest() monsterrandtest() randtestschuss() schiessen() schussmalen() gegner() collision() drawenemy() mapcollision() hud() Flip Until KeyHit(1) End Function drawlevel() for xmap = 0 to 19 for ymap = 0 to 9 drawimage map,xmap*32,ymap*32,level(xmap,ymap) next next End Function function mapcollision() end function function hud() drawimage energy1,0,383 Text 20,10, "Player1: "+punkte+" Punkte" Text 50,415, " "+life+" %" Text 35,365,"Player 1" end function function randtestschuss() for l = 0 to 40 if schuss(0,l,2) < 0 then schuss(0,l,0) = 0 if schuss(1,l,1) < 0 then schuss(1,l,0) = 0 if schuss(2,l,2) > 320 then schuss(2,l,0) = 0 if schuss(3,l,1) > 640 then schuss(3,l,0) = 0 next end function function monsterrandtest() for l = 0 to 5 if monster(l,1) > 600 then monster(l,1) = 600 if monster(l,1) < 0 then monster(l,1) = 0 if monster(l,2) > 320 then monster(l,2) = 320 if monster(l,2) < 0 then monster(l,2) = 0 next end function function collision() for l = 0 to 40 for i = 0 to 5 if imagesoverlap(boom,schuss(0,l,1),schuss(0,l,2),enemy,monster(i,1),monster(i,2)) and monster(i,0) =1 and schuss(0,l,0) = 1 then monster(i,3) = monster(i,3) - 1 punkte = punkte + 1 schuss(0,l,0) = 0 endif if imagesoverlap(boom,schuss(1,l,1),schuss(1,l,2),enemy,monster(i,1),monster(i,2)) and monster(i,0) =1 and schuss(1,l,0) = 1 then monster(i,3) = monster(i,3) - 1 punkte = punkte + 1 schuss(1,l,0) = 0 endif if imagesoverlap(boom,schuss(2,l,1),schuss(2,l,2),enemy,monster(i,1),monster(i,2)) and monster(i,0) =1 and schuss(2,l,0) = 1 then monster(i,3) = monster(i,3) - 1 punkte = punkte + 1 schuss(2,l,0) = 0 endif if imagesoverlap(boom,schuss(3,l,1),schuss(3,l,2),enemy,monster(i,1),monster(i,2)) and monster(i,0) =1 and schuss(3,l,0) = 1 then monster(i,3) = monster(i,3) - 1 punkte = punkte + 1 schuss(3,l,0) = 0 endif if monster(i,3) = 0 then monster(i,0) = 0 next next for l = 0 to 5 if imagesoverlap(player,x,y,enemy,monster(l,1),monster(l,2)) and monster(l,0) = 1 then life = life - 1 x = x + 5 y = y + 5 drawimage damage,170,350 if life < 0 then Text 200,200, "Du bist tot" waitkey end endif endif next end function function gegner() for l = 0 to 5 if monster(l,0) = 0 then monster(l,0) = 1 monster(l,1) = rnd(0,640) monster(l,2) = rnd(0,290) monster(l,3) = 20 endif next for l = 0 to 5 if monster(l,1) > x then zg = 1 movemonster = rnd(1,6) select movemonster case 1,2 monster(l,1) = monster(l,1) - 1 end select endif if monster(l,1) < x then zg = 2 movemonster = rnd(1,6) select movemonster case 1,2 monster(l,1) = monster(l,1) + 1 end select endif if monster(l,2) > y then zg = 3 movemonster = rnd(1,6) select movemonster case 1,2 monster(l,2) = monster(l,2) - 1 end select endif if monster(l,2) < y then zg = 4 movemonster = rnd(1,6) select movemonster case 1,2 monster(l,2) = monster(l,2) + 1 case 6,7 end select endif next end function function drawenemy() for l = 0 to 5 if zg = 1 and monster(l,0) = 1 then drawimage enemy, monster(l,1), monster(l,2), 3 endif if zg = 2 and monster(l,0) = 1 then drawimage enemy, monster(l,1), monster(l,2), 0 endif if zg = 3 and monster(l,0) = 1 then drawimage enemy, monster(l,1), monster(l,2), 1 endif if zg = 4 and monster(l,0) = 1 then drawimage enemy, monster(l,1), monster(l,2), 2 endif next end function Function drawplayer() DrawImage player, x, y, frame End Function Function randtest() If x < 0 Then x = 0 If x > 613 Then x = 613 If y < 0 Then y = 0 If y > 290 Then y = 290 If x2 < 0 Then x2 = 0 If x2 > 613 Then x2 = 613 If y2 < 0 Then y2 = 0 If y2 > 290 Then y2 = 290 End Function Function moveplayer() If KeyDown(oben) and (not keydown(rechts)) and (not keydown(links)) and (not keydown(unten)) and movey = 1 Then If frame > 14 Then frame = 0 counter = counter - 1 If counter = 0 Then counter = 2 frame = frame + 1 y = y - 3 z = 1 EndIf EndIf If KeyDown(links) and (not keydown(rechts)) and (not keydown(oben)) and (not keydown(unten)) and movex = 1 Then If frame > 30 Then frame = 16 If frame < 16 Then frame = 16 counter = counter - 1 If counter = 0 Then counter = 2 frame = frame + 1 x = x - 3 z = 2 EndIf EndIf If KeyDown(unten) and (not keydown(rechts)) and (not keydown(links)) and (not keydown(oben)) and movey = 1 Then If frame > 46 Then frame = 32 If frame < 32 Then frame = 32 counter = counter - 1 If counter = 0 Then counter = 2 frame = frame + 1 y = y + 3 z = 3 EndIf EndIf If KeyDown(rechts) and (not keydown(oben)) and (not keydown(links)) and (not keydown(unten)) and movex = 1 Then If frame > 62 Then frame = 48 If frame < 48 Then frame = 48 counter = counter - 1 If counter = 0 Then counter = 2 frame = frame + 1 x = x + 3 z = 4 EndIf EndIf End Function Function schiessen() If Keydown(strg) And z = 1 and (not keydown(oben)) and (not keydown(links)) and (not keydown(unten)) and (not keydown(rechts)) Then playsound mg shoot = shoot + 1 if shoot = 40 then shoot = 0 schuss(0,shoot,0) = 1 schuss(0,shoot,1) = x + 20 schuss(0,shoot,2) = y If frame > 64 Then frame = 64 If frame < 64 Then frame = 64 counter = counter - 1 If counter = 0 Then counter = 8 frame = frame + 1 EndIf Endif If Keydown(strg) And z = 2 and (not keydown(oben)) and (not keydown(links)) and (not keydown(unten)) and (not keydown(rechts)) Then playsound mg shoot = shoot + 1 if shoot = 40 then shoot = 0 schuss(1,shoot,0) = 1 schuss(1,shoot,1) = x schuss(1,shoot,2) = y + 9 If frame > 66 Then frame = 66 If frame < 66 Then frame = 66 counter = counter - 1 If counter = 0 Then counter = 8 frame = frame + 1 endif endif If KeyDOWN(strg) And z = 3 and (not keydown(oben)) and (not keydown(links)) and (not keydown(unten)) and (not keydown(rechts)) Then playsound mg shoot = shoot + 1 if shoot = 40 then shoot = 0 schuss(2,shoot,0) = 1 schuss(2,shoot,1) = x + 12 schuss(2,shoot,2) = y + 22 If frame > 68 Then frame = 68 If frame < 68 Then frame = 68 counter = counter - 1 If counter = 0 Then counter = 8 frame = frame + 1 EndIf endif If KeyDOWN(strg) And z = 4 and (not keydown(oben)) and (not keydown(links)) and (not keydown(unten)) and (not keydown(rechts)) Then playsound mg shoot = shoot + 1 if shoot = 40 then shoot = 0 schuss(3,shoot,0) = 1 schuss(3,shoot,1) = x + 25 schuss(3,shoot,2) = y + 10 If frame > 70 Then frame = 70 If frame < 70 Then frame = 70 counter = counter - 1 If counter = 0 Then counter = 8 frame = frame + 1 EndIf endif End Function function schussmalen() for l = 0 to 20 if schuss(0,l,0) = 1 then drawimage boom, schuss(0,l,1), schuss(0,l,2) schuss(0,l,2) = schuss(0,l,2) - 10 endif next if bremse + 10000 < Millisecs() then for l = 21 to 40 if schuss(0,l,0) = 1 then drawimage boom, schuss(0,l,1), schuss(0,l,2) schuss(0,l,2) = schuss(0,l,2) - 10 endif next endif for l = 0 to 20 if schuss(1,l,0) = 1 then drawimage boom, schuss(1,l,1), schuss(1,l,2) schuss(1,l,1) = schuss(1,l,1) - 10 endif next if bremse + 10000 < Millisecs() then for l = 21 to 40 if schuss(0,l,0) = 1 then drawimage boom, schuss(0,l,1), schuss(0,l,2) schuss(0,l,1) = schuss(0,l,1) - 10 endif next endif for l = 0 to 20 if schuss(2,l,0) = 1 then drawimage boom, schuss(2,l,1), schuss(2,l,2) schuss(2,l,2) = schuss(2,l,2) + 10 endif next if bremse + 10000 < Millisecs() then for l = 21 to 40 if schuss(0,l,0) = 1 then drawimage boom, schuss(0,l,1), schuss(0,l,2) schuss(0,l,2) = schuss(0,l,2) + 10 endif next endif for l = 0 to 20 if schuss(3,l,0) = 1 then drawimage boom, schuss(3,l,1), schuss(3,l,2) schuss(3,l,1) = schuss(3,l,1) + 10 endif next if bremse + 10000 < Millisecs() then for l = 21 to 40 if schuss(0,l,0) = 1 then drawimage boom, schuss(0,l,1), schuss(0,l,2) schuss(0,l,1) = schuss(0,l,1) + 10 endif next endif end function Levels.bb Code: [AUSKLAPPEN] data 1,1,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,0,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,0,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,0,1,1,2,1,1,0,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 data 1,1,1,1,2,1,1,1,1,1 |
||
OJay |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
OJay hat Folgendes geschrieben: setze vor dein data field ein label: Code: [AUSKLAPPEN]
.meinlevel
und dann vor deinen for-schleifen, die das einlesen ein: Code: [AUSKLAPPEN] data 1,24,04,0,2,3 restore meinlevel
damit setzt du den "zeiger" direkt vor das richtige datafield. wichtig, wenn man mehrere anlegt... lies es dir nochmal ganz genau durch, und dann versuch von selbst drauf zu kommen, was du vergessen hast ![]() |
||
![]() |
RallimenSieger des 30-EUR-Wettbewerbs |
![]() Antworten mit Zitat ![]() |
---|---|---|
also 1 Fehler hab ich schon gefunden
so muss min. Dim level(19,9) so isses im Augenblick Dim level(10,20) leve1 hab ich nicht gefunden weder als Sprungadresse noch als Gosub oder function ich habe nicht alle Bilder und kann es deswegen nicht testen aber das oberere mit Dim ist es auf jeden Fall schon mal... |
||
[BB2D | BB3D | BB+]
|
![]() |
Julz |
![]() Antworten mit Zitat ![]() |
---|---|---|
Also du hast recht das war en fehler allerdings geht es immer noch nicht ich werd noch krank,
hab jetzt data 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 data 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 data 1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 data 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 data 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 data 1,0,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1 data 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 data 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 data 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 data 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 die 2en sind mein weg aber wenn ich das level jetzt starte dann geht der weg von oben nach unten und nicht von links nach rechts ![]() |
||
![]() |
RallimenSieger des 30-EUR-Wettbewerbs |
![]() Antworten mit Zitat ![]() |
---|---|---|
ist doch klar warum
die y Schleife steht in der mitte deswegen hast du einen doppeltbreiten weg du musst die Datas so einlesen Code: [AUSKLAPPEN] for ymap = 0 to 9 ;zeile jeweils 1 runter for xmap = 0 to 19 ; weil x doch die waagerechte ist read data level (xmap,ymap); werden hier die data waagerecht gelesen, next next ; zeichnen for ymap = 0 to 9 for xmap = 0 to 19 ; drawimage ....... ,xmap,ymap next next so sollte es gehen, denk ich jedenfalls da ich es nicht getestet habe |
||
[BB2D | BB3D | BB+]
|
![]() |
Julz |
![]() Antworten mit Zitat ![]() |
---|---|---|
Super Rallimen ich dank dir ![]() ![]() wusste nicht das das mit den schleifen wichtig ist ich dachte das wäre egal, gut hab wieder was gelernt ![]() danke auch allen anderen die mir geholfen haben |
||
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group