Hallo alle,
das hier nur mal zur wiederholung, da immer wieder probleme mit dem Speed und Layern auftaucht.
Im folgenden Code werden 9 Layer gezeichnet,
in jedem layer werden 1024 / 32 * 786 / 32 Tiles gezeichnet,
im Letzten layer wird zus?tzlich 1024 / 32 * 786 / 32 Print ausgegeben,
ein Sprite im Tilefeld wo sich die Mouse befinden und ein Sprite direkt an der Mouseposition gezeichnet das auch Pixelgenaue collision
benutzt.
Die einzelnen layer sind real, 8000 * 8000 Pixel gross, sie k?nnte noch viel gr?sser sein ohne Frameverlust.
Das ganze l?sst sich auch noch scrollen.
Gezeichnet wird hier nur was in den 1024*768 pix von dem Bildschirm liegt, plus je 1 Tile dar?ber, damit man ein "Aufploppen" hat.
Bei mir liegt die FPS bei ca. 56-60 FPS.
Es sind extra einige Werte direkt geschrieben und nicht in Variablen gepackt,
damit man es etwas besser Nachvollziehen kann.
// --------------------------------- //
// Project: For nur im Screen
// startx: Sunday, September 20, 2009
// IDE Version: 7.115
// SETCURRENTDIR("Media") // seperate media and binaries
SYSTEMPOINTER TRUE
SETSCREEN 1024,768,0
LIMITFPS -1
DRAWRECT 0,0,32,32,RGB(0xff, 0x00, 0x00)
DRAWRECT 1,1,30,30,RGB(0xff, 0xff, 0x00)
GRABSPRITE 0,0,0,32,32
BLACKSCREEN
//F?r den Player
DRAWRECT 0,0,32,32,RGB(0x00, 0x80, 0xff)
GRABSPRITE 1,0,0,32,32
BLACKSCREEN
// gebrauchte Variablen
GLOBAL posx%, posy%, scrollx%,scrolly%,playerx%,playery%,x%,y%,z%
GLOBAL startx%,endex%,starty%,endey%,a_count%,mx%,my%,b1%,b2%
WHILE TRUE
MOUSESTATE mx,my,b1,b2
IF KEY(205)
DEC posx,2
ENDIF
IF KEY(203)
INC posx,2
ENDIF
endex = startx + 1024 / 32
IF endex > 249 THEN endex = 249
startx = ABS(posx/32)
IF startx < 0 THEN startx = 0
IF startx > 249 THEN startx = 249
IF posx > 0 THEN posx = 0
IF posx < 0 - 250 * 32 + 1024 THEN posx = 0 - 250 * 32 + 1024
//-------------------------------------------------------------------------
IF KEY(208)
DEC posy,2
ENDIF
IF KEY(200)
INC posy,2
ENDIF
endey = starty + 768 / 32
IF endey > 249 THEN endey = 249
starty = ABS(posy/32)
IF starty < 0 THEN starty = 0
IF starty > 249 THEN starty = 249
IF posy > 0 THEN posy = 0
IF posy < 0 - 250 * 32 + 768 THEN posy = 0 - 250 * 32 + 768
//-------------------------------------------------------------------------
FOR z = 0 TO 8
FOR y = starty TO endey
FOR x = startx TO endex
DRAWSPRITE 0,posx + x*32 ,posy + y * 32
IF z = 8
PRINT "D2O",posx + x*32 ,posy + y * 32
IF mx > posx + x*32 AND mx < posx + x*32 +32 AND my > posy + y * 32 AND my < posy + y * 32+32 THEN DRAWSPRITE 1,posx + x*32 ,posy + y * 32
DRAWSPRITE 1,mx,my
IF SPRCOLL (1,mx,my,0,posx + x*32 ,posy + y * 32)
PRINT "Collision",mx,my
ENDIF
ENDIF
NEXT
NEXT
NEXT
//-------------------------------------------------------------------------
//PRINT startx,10,200
//PRINT endex,10,230
//PRINT 0 - 50 * 32 +1024,10,260
DRAWRECT 580,5,70,15,RGB(0x11, 0x11, 0x11)
PRINT getfps()+" FPS",580,10
SHOWSCREEN
WEND
FUNCTION getfps:
STATIC fps_time%,fps_counter%,fps%,fps_temp%
fps_time = GETTIMERALL()
fps_counter = fps_counter + 1
IF (fps_time-fps_temp)>1000
fps_temp = fps_time
fps = fps_counter
fps_counter = 0
ENDIF
RETURN fps
ENDFUNCTION
Find ich gut ;)
:good: evtl machst ja mal ein Tilemap-tutorial?
Ich mach mich jetzt erstmal an ein Typetutorial ran :whistle:
hast du auch ICQ D?O ?
Quote from: Schranz0r on 2009-Sep-20
...
hast du auch ICQ D?O ?
Nein, hatte ich mal, war aber nie so ?berzeugt von dem.
Quote from: Schranz0r on 2009-Sep-20
..
:good: evtl machst ja mal ein Tilemap-tutorial?
Ich mach mich jetzt erstmal an ein Typetutorial ran :whistle:
Bin ?berredet :)
Habe gestern mal angefangen,
Einfache 3 Layer Map
Scrolling, playerpositionsabh?ngig
Nur sichtbares in der FOR schleife ab arbeiten
ist schon alles drin,
Morgen kommt eine Tile Kollision dazu.
Das sollte eigendlich reichen.
Dann muss das ganze noch h?bsch verpackt und sauber Komentiert werden.
Wenns fertig ist, bekommst Du es zuerst zum Korrektur lesen :)
Edit:
Oops: Sorry f?r das Doppelposting
Quote from: D?O on 2009-Sep-21
Edit:
Oops: Sorry f?r das Doppelposting
br?ller! xD