Wie schnell läuft es bei Euch ?
Übersicht

![]() |
LordArtusBetreff: Wie schnell läuft es bei Euch ? |
![]() Antworten mit Zitat ![]() |
---|---|---|
Hi,
wollte ne kleine Umfrage machen bezüglich FPS , würde mich interresieren wie schnell es bei Euch läuft , ohne Bewegung und mit Bewegung bei Flip 0. Pfeiltasten: bewegen Code: Code: [AUSKLAPPEN] '--------------------------' '-------- DEFENDER --------.' '---------- 2007 ----------.' '--------------------------.' '-- Remake -by LordArtus --.' '--------------------------.' '...........................' 'Ver.Alpha 0.5 '------------- SuperStrict SeedRnd MilliSecs() SetGraphicsDriver GLMax2DDriver() 'ToDo genaue Überprüfung des Spiels bei Auflösungswechsel und wie es auf FPS-Unterschiede reagiert Const GX:Int=1024 Const GY:Int=768 Const MAPSIZEX:Float=5120.0 Const MAPSIZEY:Int=GY-GY/5 Const MAPYNULL:Int=GY/5 Const STARS_LIMIT1:Int=500 Const STARS_LIMIT2:Int=1000 Const STARS_LIMIT3:Int=1500 Graphics GX,GY,32 ' Types und Funktionen '---------------------- Type Player Field x:Float Field y:Float Field speedx:Float Field speedy:Float Field le_ri_flag:Byte Field up_do_flag:Byte Field shoot_flag:Byte Field stop_flag:Byte Field ShootList:TList Field wait:Int Method MoveLeft(cam_speed:Float) speedx=cam_speed x=x-speedx If x<0.0 x=x+MAPSIZEX EndIf stop_flag=False EndMethod Method MoveRight(cam_speed:Float) speedx=cam_speed x=x+speedx If x>MAPSIZEX x=x-MAPSIZEX EndIf stop_flag=False EndMethod Method MoveUp() If y>MAPYNULL+7 y=y-speedy EndIf EndMethod Method MoveDown() If y<GY-GY/10 y=y+speedy EndIf EndMethod Method Shoot() If wait+150<MilliSecs() ShootList.AddLast(PlayerShoot.Create(x,y,shoot_flag)) wait=MilliSecs() EndIf EndMethod Method Bomb() EndMethod Method Draw(cam_posx:Float) SetColor 255,255,255 If x<GX And cam_posx>MAPSIZEX-GX If CollideRect(x+MAPSIZEX-cam_posx,y,PLAYERWIDTH,PLAYERHEIGHT,2,0) SetColor 255,0,255 EndIf If shoot_flag DrawRect x+MAPSIZEX-cam_posx,y,PLAYERWIDTH,PLAYERHEIGHT DrawLine x+MAPSIZEX-cam_posx,y,x+MAPSIZEX-cam_posx,y-5 DrawLine x+MAPSIZEX-cam_posx,y-5,x+MAPSIZEX-cam_posx+PLAYERWIDTH/2,y SetColor 0,0,0 DrawRect (x+MAPSIZEX-cam_posx)+1,y+1,PLAYERWIDTH/2,PLAYERHEIGHT-2 Else DrawRect x+MAPSIZEX-cam_posx,y,PLAYERWIDTH,PLAYERHEIGHT DrawLine x+MAPSIZEX-cam_posx+PLAYERWIDTH-1,y,x+MAPSIZEX-cam_posx+PLAYERWIDTH-1,y-5 DrawLine x+MAPSIZEX-cam_posx+PLAYERWIDTH-1,y-5,x+MAPSIZEX-cam_posx+PLAYERWIDTH/2,y SetColor 0,0,0 DrawRect (x+MAPSIZEX-cam_posx)+PLAYERWIDTH/2-1,y+1,PLAYERWIDTH/2,PLAYERHEIGHT-2 EndIf CollideRect(x+MAPSIZEX-cam_posx,y,PLAYERWIDTH,PLAYERHEIGHT,0,1) SetColor 0,255,255 DrawRect (x+MAPSIZEX-cam_posx)/10+(GX/2-GX/20)-1,GY/12+y/10-1,3,3 ' Anzeige des Raumschiffs im HUD Else If CollideRect(x-cam_posx,y,PLAYERWIDTH,PLAYERHEIGHT,2,0) SetColor 255,0,255 EndIf If shoot_flag DrawRect x-cam_posx,y,PLAYERWIDTH,PLAYERHEIGHT DrawLine x-cam_posx,y,x-cam_posx,y-5 DrawLine x-cam_posx,y-5,x-cam_posx+PLAYERWIDTH/2,y SetColor 0,0,0 DrawRect (x-cam_posx)+1,y+1,PLAYERWIDTH/2,PLAYERHEIGHT-2 Else DrawRect x-cam_posx,y,PLAYERWIDTH,PLAYERHEIGHT DrawLine x-cam_posx+PLAYERWIDTH-1,y,x-cam_posx+PLAYERWIDTH-1,y-5 DrawLine x-cam_posx+PLAYERWIDTH-1,y-5,x-cam_posx+PLAYERWIDTH/2,y SetColor 0,0,0 DrawRect (x-cam_posx)+PLAYERWIDTH/2-1,y+1,PLAYERWIDTH/2,PLAYERHEIGHT-2 EndIf CollideRect(x-cam_posx,y,PLAYERWIDTH,PLAYERHEIGHT,0,1) SetColor 0,255,255 DrawRect (x-cam_posx)/10+(GX/2-GX/20)-1,GY/12+y/10-1,3,3 ' Anzeige des Raumschiffs im HUD EndIf EndMethod Function Create:Player(startx:Float) Local cp:Player=New Player cp.ShootList=New TList cp.x=startx cp.y=GY/2 cp.speedy=6.0 cp.shoot_flag=True cp.stop_flag=True cp.le_ri_flag=cp.shoot_flag cp.up_do_flag=0 ' ToDo am Überlegen wegen Vertikal-Beschleunigung cp.wait=0 Return cp EndFunction EndType Type PlayerShoot Field x:Float Field y:Float Field speed:Float Field shoot_flag:Byte Method Move:Byte(cam_posx:Float) If x<0.0 x=x+MAPSIZEX EndIf If x>MAPSIZEX x=x-MAPSIZEX EndIf If x<GX And cam_posx>MAPSIZEX-GX If shoot_flag If x+PLAYERWIDTH+MAPSIZEX<cam_posx+GX x=x+speed Return True Else Return False EndIf Else If x+MAPSIZEX>cam_posx x=x-speed Return True Else Return False EndIf EndIf Else If shoot_flag If x+PLAYERWIDTH<cam_posx+GX x=x+speed Return True Else Return False EndIf Else If x-speed>cam_posx x=x-speed Return True Else Return False EndIf EndIf EndIf EndMethod Method Draw(cam_posx:Float) SetColor 255,255,0 If x<GX And cam_posx>MAPSIZEX-GX If shoot_flag DrawLine x+PLAYERWIDTH+MAPSIZEX-cam_posx,y,x+PLAYERWIDTH+20+MAPSIZEX-cam_posx,y CollideRect(x+PLAYERWIDTH+MAPSIZEX-cam_posx,y-1,20,3,0,1) Else DrawLine x+MAPSIZEX-cam_posx,y,(x-20)+MAPSIZEX-cam_posx,y CollideRect(x+MAPSIZEX-cam_posx,y-1,-20,3,0,1) EndIf Else If shoot_flag DrawLine x+PLAYERWIDTH-cam_posx,y,x+PLAYERWIDTH+20-cam_posx,y CollideRect(x+PLAYERWIDTH-cam_posx,y-1,20,3,0,1) Else DrawLine x-cam_posx,y,(x-20)-cam_posx,y CollideRect(x-cam_posx,y-1,-20,3,0,1) EndIf EndIf EndMethod Function Create:PlayerShoot(x:Int,y:Int,shoot_flag:Byte) Local ps:PlayerShoot=New PlayerShoot ps.x=x ps.y=y ps.speed=15.0 ps.shoot_flag=shoot_flag Return ps EndFunction EndType Type Enemy Field x:Float Field y:Float Field speedx:Float Field speedy:Float Field changespeedwait:Int Field rtime:Int Method Move() 'Nur zu Testzwecken '------------------------------------ If changespeedwait+rtime<MilliSecs() speedx=Rnd(-1.0,1.0) speedy=Rnd(-1.0,1.0) rtime=Rand(5000,15000) changespeedwait=MilliSecs() EndIf '------------------------------------ x=x+speedx y=y+speedy If x>MAPSIZEX x=x-MAPSIZEX EndIf If x<0.0 x=x+MAPSIZEX EndIf If y<MAPYNULL-speedy Or y>GY-ENEMYHEIGHT-speedy speedy=-speedy EndIf EndMethod Method Shoot:Byte() Return True EndMethod Method Draw(cam_posx:Float) SetColor 0,255,0 Local xdraw:Float=x-cam_posx If (xdraw<GX And xdraw+ENEMYWIDTH>0) Or (xdraw>-MAPSIZEX And xdraw<-(MAPSIZEX-GX)) If x<GX And cam_posx>MAPSIZEX-GX If CollideRect(xdraw+MAPSIZEX,y,ENEMYWIDTH,ENEMYHEIGHT,1,0) SetColor 255,0,0 EndIf DrawOval xdraw+MAPSIZEX,y,ENEMYWIDTH,ENEMYHEIGHT CollideRect(xdraw+MAPSIZEX,y,ENEMYWIDTH,ENEMYHEIGHT,0,2) Else If CollideRect(xdraw,y,ENEMYWIDTH,ENEMYHEIGHT,1,0) SetColor 255,0,0 EndIf DrawOval xdraw,y,ENEMYWIDTH,ENEMYHEIGHT CollideRect(xdraw,y,ENEMYWIDTH,ENEMYHEIGHT,0,2) EndIf EndIf DrawEnemyOnHUD(x,y,cam_posx) EndMethod Function Create:Enemy() Local ce:Enemy=New Enemy ce.speedx=Rnd(-1.0,1.0) ce.speedy=Rnd(-1.0,1.0) ce.x=Rand(0,MAPSIZEX) ce.y=Rand(MAPYNULL,MAPYNULL+MAPSIZEY-10) ce.changespeedwait=MilliSecs() ce.rtime=5000 Return ce EndFunction EndType Function DrawEnemyOnHUD(x:Float,y:Float,cam_posx:Float) Local xhud:Float=(x+MAPSIZEX/2-GX/2)/10 Local camposxhud:Float=cam_posx/10 If xhud>MAPSIZEX/10 xhud=xhud-MAPSIZEX/10 EndIf If xhud-camposxhud<0 xhud=xhud+MAPSIZEX/10 EndIf SetColor 200,200,200 Plot (xhud-camposxhud)+(GX/2-MAPSIZEX/20),GY/12+y/10 ' Anzeige im HUD EndFunction '------------------------- '--------- ToDo ---------- '------------------------- Type EnemyShoot EndType Type EnemyKI ' Vielleicht reicht da Function() EndType Type PlayerExplosion ' Vielleicht reicht da Function() EndType Type EnemyExplosion EndType '------------------------- '------------------------- Type H_U_D Field x:Int Field y:Int Field wait:Int Field mem:Int Method Draw(Score:Int,Lives:Int,Bombs:Int,cam_posx:Int,px:Int,cs:Float,shootlist:TList,us:Float) SetColor 255,255,255 DrawLine x,y+MAPYNULL,x+GX,y+MAPYNULL DrawLine GX/2-MAPSIZEX/20,y,GX/2-MAPSIZEX/20,MAPYNULL DrawLine GX/2+MAPSIZEX/20,y,GX/2+MAPSIZEX/20,MAPYNULL '--------------------------- DrawLine GX/2-GX/20,GY/12+MAPYNULL/10,GX/2+GX/20,GY/12+MAPYNULL/10 DrawLine GX/2+GX/20,GY/12+MAPYNULL/10,GX/2+GX/20,GY/12+MAPYNULL/10+MAPSIZEY/10 DrawLine GX/2+GX/20,GY/12+MAPYNULL/10+MAPSIZEY/10,GX/2-GX/20,GY/12+MAPYNULL/10+MAPSIZEY/10 DrawLine GX/2-GX/20,GY/12+MAPYNULL/10+MAPSIZEY/10,GX/2-GX/20,GY/12+MAPYNULL/10 '---------------------------- DrawText "Score: "+Score,130,120 DrawText "Lives: "+Lives,130,132 DrawText "Bombs: "+Bombs,130,144 ' Zum Testzwecken '----------------- DrawText "camposx: "+cam_posx,0,12 DrawText "playerposx: "+px,0,24 DrawText "camspeed: "+cs,0,36 If shootlist=Null DrawText "shoots: "+0,0,48 Else DrawText "shoots: "+CountList(shootlist),0,48 EndIf DrawText "upd_speed: "+us,0,60 If wait+999<MilliSecs() mem=GCMemAlloced() wait=MilliSecs() EndIf DrawText "Speicher: "+mem+" bytes",0,72 DrawLine 0,90,GX/2-MAPSIZEX/20,90 '----------------- EndMethod Function Create:H_U_D() Local hud:H_U_D=New H_U_D hud.x=0 hud.y=0 hud.wait=MilliSecs() hud.mem=GCMemAlloced() Return hud EndFunction EndType Type Background Field x1:Float[] Field y1:Float[] Field x2:Float[] Field y2:Float[] Field x3:Float[] Field y3:Float[] Field r1:Float Field r2:Float Field r3:Float Method Draw(flag:Byte,cam_speed:Float,upd_speed:Float) If flag r1=-cam_speed r2=-cam_speed/2 r3=-cam_speed/3 Else r1=cam_speed r2=cam_speed/2 r3=cam_speed/3 EndIf For Local i:Int=0 To STARS_LIMIT3-1 x3[i]=x3[i]+r3 If x3[i]<0 x3[i]=x3[i]+GX EndIf If x3[i]>GX x3[i]=x3[i]-GX EndIf SetColor 100,100,100 Plot x3[i],y3[i] Next For Local i:Int=0 To STARS_LIMIT2-1 x2[i]=x2[i]+r2 If x2[i]<0 x2[i]=x2[i]+GX EndIf If x2[i]>GX x2[i]=x2[i]-GX EndIf SetColor 180,180,180 Plot x2[i],y2[i] Next For Local i:Int=0 To STARS_LIMIT1-1 x1[i]=x1[i]+r1 If x1[i]<0 x1[i]=x1[i]+GX EndIf If x1[i]>GX x1[i]=x1[i]-GX EndIf SetColor 250,250,250 If r1>0.0 For Local s:Int=0 To Abs(r1*upd_speed) SetColor 250-s*15,250-s*15,250-s*15 Plot x1[i]-s,y1[i] Next ElseIf r1<0.0 For Local s:Int=0 To Abs(r1*upd_speed) SetColor 250-s*15,250-s*15,250-s*15 Plot x1[i]+s,y1[i] Next Else Plot x1[i],y1[i] EndIf Next EndMethod Function Create:Background() Local bgr:Background=New Background bgr.x1=New Float[STARS_LIMIT1] bgr.y1=New Float[STARS_LIMIT1] bgr.x2=New Float[STARS_LIMIT2] bgr.y2=New Float[STARS_LIMIT2] bgr.x3=New Float[STARS_LIMIT3] bgr.y3=New Float[STARS_LIMIT3] For Local i:Int=0 To STARS_LIMIT1-1 bgr.x1[i]=Rand(0,GX) bgr.y1[i]=Rand(MAPYNULL,GY-GY/10) Next For Local i:Int=0 To STARS_LIMIT2-1 bgr.x2[i]=Rand(0,GX) bgr.y2[i]=Rand(MAPYNULL,GY-GY/10) Next For Local i:Int=0 To STARS_LIMIT3-1 bgr.x3[i]=Rand(0,GX) bgr.y3[i]=Rand(MAPYNULL,GY-GY/10) Next Return bgr EndFunction EndType Type World Field cam_posx:Float Field cam_speed:Float Field cam_flag:Byte Field cam_stop_value:Float Field cam_max_speed:Float Field _player:Player Field _EnemyList:TList ' ToDo EnemyListe in Enemy-Type reinpacken Field _EnemyShootList:TList Field _background:Background Field _HUD:H_U_D Field PlayerScore:Int Field PlayerLives:Int Field PlayerBombs:Int Field upd_speed:Float Method UpdateWorld(upd_speed:Float) ' ToDo die Steuerung noch richtig anpassen ' ToDo inteligente Kameraverfolgung (Grundgerüst vorhanden) einbauen ResetCollisions(1) _player.stop_flag=True If KeyDown(KEY_LEFT) And Not KeyDown(KEY_RIGHT) _player.shoot_flag=False If _player.le_ri_flag=True And cam_speed>0.0 Else _player.le_ri_flag=False If cam_speed<(cam_max_speed/upd_speed) cam_speed=cam_speed+(0.08/upd_speed) Else cam_speed=(cam_max_speed/upd_speed) EndIf If cam_speed=(cam_max_speed/upd_speed) cam_posx=cam_posx-cam_speed Else cam_posx=cam_posx-cam_speed EndIf If cam_posx<0.0 cam_posx=cam_posx+MAPSIZEX EndIf _player.MoveLeft(cam_speed) EndIf EndIf If KeyDown(KEY_RIGHT) And Not KeyDown(KEY_LEFT) _player.shoot_flag=True If _player.le_ri_flag=False And cam_speed>0.0 Else _player.le_ri_flag=True If cam_speed<(cam_max_speed/upd_speed) cam_speed=cam_speed+(0.08/upd_speed) Else cam_speed=(cam_max_speed/upd_speed) EndIf If cam_speed=(cam_max_speed/upd_speed) cam_posx=cam_posx+cam_speed Else cam_posx=cam_posx+cam_speed EndIf If cam_posx>MAPSIZEX cam_posx=cam_posx-MAPSIZEX EndIf _player.MoveRight(cam_speed) EndIf EndIf If _player.stop_flag ' True = Anhalten If cam_speed=0.0 Else If KeyDown(KEY_RIGHT) Or KeyDown(KEY_LEFT) cam_speed=cam_speed-(0.12/upd_speed) Else cam_speed=cam_speed-(0.04/upd_speed) EndIf If cam_speed<0.0 cam_speed=0.0 EndIf If _player.le_ri_flag cam_posx=cam_posx+cam_speed If cam_posx>MAPSIZEX cam_posx=cam_posx-MAPSIZEX EndIf _player.MoveRight(cam_speed) Else cam_posx=cam_posx-cam_speed If cam_posx<0.0 cam_posx=cam_posx+MAPSIZEX EndIf _player.MoveLeft(cam_speed) EndIf EndIf EndIf If MouseDown(1) _player.Shoot() If MouseHit(2) _player.Bomb() ' ToDo Noch am Überlegen wegen der _player.Bomb Lösung If KeyDown(KEY_UP) _player.MoveUp() If KeyDown(KEY_DOWN) _player.MoveDown() _background.Draw(_player.le_ri_flag,cam_speed,upd_speed) _player.Draw(cam_posx) ResetCollisions(2) For Local ps:PlayerShoot=EachIn _player.ShootList If ps.Move(cam_posx) ps.Draw(cam_posx) Else ListRemove(_player.ShootList,ps) ' ToDo RemoveLink() EndIf Next For Local en:Enemy=EachIn _EnemyList en.Move() en.Draw(cam_posx) Next Rem For ens:EnemyShoot=EachIn _EnemyShootList If ens.Move() ens.Draw() EndIf Next EndRem _HUD.Draw(PlayerScore,PlayerLives,PlayerBombs,cam_posx,_player.x,cam_speed,_player.ShootList,upd_speed) EndMethod Function Create:World() Local cw:World=New World cw.cam_posx=1000.0 ' Startposition der Kamera cw.cam_speed=0.0 cw.cam_max_speed=10.0 ' 10 Pixel bei 85FPS cw.cam_flag=True cw.cam_stop_value=0.04 cw._player=Player.Create(cw.cam_posx+GX/2) ' Startposition des Spielers cw._EnemyList:TList=New TList For Local i:Int=0 To 250 ' Anzahl Enemys cw._EnemyList.AddLast(Enemy.Create()) Next cw._EnemyShootList:TList=New TList cw._background=Background.Create() cw._HUD=H_U_D.Create() cw.PlayerScore=0 cw.PlayerLives=5 cw.PlayerBombs=3 Return cw EndFunction EndType 'Globale Variablen '------------------------------------------ Global Game1:World=World.Create() Global PLAYERWIDTH:Int=40 Global PLAYERHEIGHT:Int=10 Global ENEMYWIDTH:Int=10 Global ENEMYHEIGHT:Int=10 ' HauptSchleife '------------------------------ Local a:Int=MilliSecs() Local fps:Short=0 Local upd_speed:Float=0.0 Local z:Short=0 While Not KeyHit(KEY_ESCAPE) If a+999<MilliSecs() a=MilliSecs() fps=z upd_speed=fps/85.0 z=0 EndIf Cls If fps>0 Game1.UpdateWorld(upd_speed) Else Game1.UpdateWorld(1.0) EndIf DrawText "FPS: "+fps,0,0 Flip 1 z=z+1 Wend End Danke im Vorraus. MfG LordArtus |
||
![]() |
Abrexxes |
![]() Antworten mit Zitat ![]() |
---|---|---|
Athlon 2600+XP(Barton)/Asus K7N8X/GeForce 6600GT GS
Ohne Beschleunigung/Volles Tempo Flip 1 : 60 / 60 Flip 0 : 178 / 99 cu |
||
![]() |
BladeRunnerModerator |
![]() Antworten mit Zitat ![]() |
---|---|---|
Notebook mit 2*1.66 GHz, 2.5 GB Ram, ATI Mobility x1600 / 256MB.
flip1: 60/60 flip0: 840/430 Aber: Die Geschwindigkeit aller Objekte hängt noch mit der Framerate zusammen - mit Flip 0 wäre das Game nicht spielbar da es zu flott rennt. Auch die eigenen Schüsse sind dann so schnell dass sie de facto nichtr mehr richtig wahrzunehmen sind. |
||
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 |
![]() |
LordArtus |
![]() Antworten mit Zitat ![]() |
---|---|---|
Nur die Bewegung des Spielers ist FPS unabhängig(erstmal zum Testzwecken) , die anderen Sachen hab ich noch nicht gemacht , aber das ist Arbeit von max.30min.
Mich interresiert eigentlich nur die Geschwindigkeit bei Euch , weil der Sternen-Hintergrund frisst am meisten Performance und ich am Überlegen bin , ob ich es anders machen soll.Den kann man auch in der Methode UpdateWorld() auskommentieren (_background.Draw(..)). MfG LordArtus |
||
Dreamora |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Du könntest auch einfach den GPU Lock Befehl da raus werfen (-> Plot) und statt Plot ein 1x1 Bild weiss zeichnen, das wäre 10 - 100 Mal schneller vermutlich.
Meine Performance Angaben spar ich mir, die wären sinnfrei für den gewünschten Test ![]() |
||
Ihr findet die aktuellen Projekte unter Gayasoft und könnt mich unter @gayasoft auf Twitter erreichen. |
![]() |
LordArtus |
![]() Antworten mit Zitat ![]() |
---|---|---|
Hi,
Draemora , wirst nicht glauben , aber habs schon probiert , Plot ist da schneller um 50% (zumindest bei mir). MfG LordArtus p.s. Aber glaube es hat was mit der GPU zu tun , bei manchen wäre sicher ein 1x1 Bild schneller. Edit : Und ausserdem , bitte poste die Werte Dreamora , mir geht es hauptsächlich um die schwächeren Kisten , hab selber (ne Höllenmaschine;) ) und kann fast sonst es nirgends testen. |
||
ChristianK |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
@Dreamora
wäre schon seltsam, wenn Plot langsamer wäre als DrawImage ( oder Rect ). Anders als Blitz2D rendert Max2D einen Plot als D3D-Primitive und nicht über GDI. Für ein Image bräuchte man immerhin 4 Verts, für Plot nur einen. @LordArtus Beim Fliegen 380 FPS, sonst 660. Specs -> siehe Signatur |
||
AdvanceLcd
Intel Core 2 Duo 3.2 GHz, 4 GB RAM, GeForce 8800 GTX | MacBook Pro 15,4″ Intel Core 2 Duo 2.4 GHz, 2 GB RAM, GeForce 8600M GT |
![]() |
LordArtus |
![]() Antworten mit Zitat ![]() |
---|---|---|
Interesant ist , dass :
Code: [AUSKLAPPEN] glBegin(GL_POINTS) glVertex2f 100,100 glEnd um ca. 20% schneller ist als Plot 100,100 , obwohl (so denke ich zumindest) , eigentlich das gleiche ist. MfG LordArtus p.s. Wie wird die DrawText-Funktion eigentlich angezeigt ? Ohne Drawtext sieht man den Punkt (oberer Code) , mit sieht man nichts. |
||
ChristianK |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Du musst vor dem Zeichnen des Punktes die Textur abschalten, die noch für den Text verwendet wurde.
Code: [AUSKLAPPEN] glDisable GL_TEXTURE_2D
glBegin GL_POINTS glVertex3f x, y, 0 glEnd Bei mir ist das genau gleich schnell wie Plot. |
||
AdvanceLcd
Intel Core 2 Duo 3.2 GHz, 4 GB RAM, GeForce 8800 GTX | MacBook Pro 15,4″ Intel Core 2 Duo 2.4 GHz, 2 GB RAM, GeForce 8600M GT |
![]() |
LordArtus |
![]() Antworten mit Zitat ![]() |
---|---|---|
Danke für den Tip (glDisable).
Code: [AUSKLAPPEN] SuperStrict SeedRnd MilliSecs() SetGraphicsDriver GLMax2DDriver() Graphics 800,600,0,2 Local a:Int=MilliSecs() Local fps:Short=0 Local z:Short=0 Local mwert:Int=0 Local g:Int=0 While Not KeyHit(KEY_ESCAPE) If a+999<MilliSecs() a=MilliSecs() fps=z mwert=mwert+fps g=g+1 z=0 EndIf Cls glEnable GL_TEXTURE_2D DrawText fps,200,200 glDisable GL_TEXTURE_2D For Local i:Int=0 To 10000 Plot 100,100 'glBegin(GL_POINTS) ' glVertex2f 100,100 'glEnd Next Flip 0 z=z+1 Wend Print mwert/g Mit Plot 1323FPS(schwankt +- 30 FPS) mit GL_POINTS 1555FPS(ziemlich stabil +-5 FPS) MfG LordArtus |
||
#ReaperNewsposter |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Bei Stillstand ~800, beim fliegen so 400-450, mal etwas mehr, oder auch mal weniger.
Btw: Kann mir einer sagen, warum nach dem Minimieren aufeinmal (obwohl Flip 0) wieder ein Framelimiter (also wie Flip 1) drinnen ist? o_O Ist das nur bei mir so, oder hat BMax einen Bug? o_O |
||
AMD Athlon 64 3500+, ATI AX800 Pro/TD, 2048 MB DRR 400 von Infineon, ♥RIP♥ (2005 - Juli 2015 -> sic!)
Blitz3D, BlitzMax, MaxGUI, Monkey X; Win7 |
Dreamora |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
ProGamer.Coder hat Folgendes geschrieben: @Dreamora
wäre schon seltsam, wenn Plot langsamer wäre als DrawImage ( oder Rect ). Anders als Blitz2D rendert Max2D einen Plot als D3D-Primitive und nicht über GDI. Für ein Image bräuchte man immerhin 4 Verts, für Plot nur einen. 1. Wären es keine GDI, Blitz nutzt nirgends GDI. Im worst case macht es das was es bei den Pixelbefehlen auf locked Pixmaps macht, nämlich nach jeder Operation aktualisieren was totaler Hirnriss ist. (das hätte oder sollte man besser in LockImage und UnlockImage verschieben wo es hingehört und wohl auch hingedacht war) 2. Nice to know. Dachte es zeichnet direkt in den Backbuffer und in dem Falle müsste es defakto diesen locken. Und wegen dem in 1. erwähnten Verhalten der Pixmap Zeichenbefehle wäre das garantiert tödlich gewesen. Generelle Idee jedoch: Wie wärs wenn du die Dinge direkt in images zeichnen würdest beim erzeugen und dann X images zeichnest statt zigtausend images. Diese Surfacereduktion würde das Spiel dir sicher danken. |
||
Ihr findet die aktuellen Projekte unter Gayasoft und könnt mich unter @gayasoft auf Twitter erreichen. |
![]() |
LordArtus |
![]() Antworten mit Zitat ![]() |
---|---|---|
Super jaaaaaaaa genau , geile Idee , werde es wahrscheinlich so machen.
Thx Dreamora. MfG LordArtus |
||
![]() |
LordArtus |
![]() Antworten mit Zitat ![]() |
---|---|---|
Ist jetzt besser bei Euch ? , weil ich merke kaum einen Unterschied.
Code: [AUSKLAPPEN] '--------------------------' '-------- DEFENDER --------.' '---------- 2007 ----------.' '--------------------------.' '-- Remake -by LordArtus --.' '--------------------------.' '...........................' 'Ver.Alpha 0.5 '------------- SuperStrict SeedRnd MilliSecs() SetGraphicsDriver GLMax2DDriver() 'ToDo genaue Überprüfung des Spiels bei Auflösungswechsel und wie es auf FPS-Unterschiede reagiert Const GX:Int=1024 Const GY:Int=768 Const MAPSIZEX:Float=5120.0 Const MAPSIZEY:Int=GY-GY/5 Const MAPYNULL:Int=GY/5 Const STARS_LIMIT1:Int=500 Const STARS_LIMIT2:Int=1000 Const STARS_LIMIT3:Int=1500 Const STARS_TILES:Int=10 ' 10 bedeutet Background wird auf 10*10 geteilt(100 Tiles) Graphics GX,GY,32 ' Types und Funktionen '---------------------- Type Player Field x:Float Field y:Float Field speedx:Float Field speedy:Float Field le_ri_flag:Byte Field up_do_flag:Byte Field shoot_flag:Byte Field stop_flag:Byte Field ShootList:TList Field wait:Int Method MoveLeft(cam_speed:Float) speedx=cam_speed x=x-speedx If x<0.0 x=x+MAPSIZEX EndIf stop_flag=False EndMethod Method MoveRight(cam_speed:Float) speedx=cam_speed x=x+speedx If x>MAPSIZEX x=x-MAPSIZEX EndIf stop_flag=False EndMethod Method MoveUp(upd_speed:Float) If y>MAPYNULL+7 y=y-(speedy/upd_speed) EndIf EndMethod Method MoveDown(upd_speed:Float) If y<GY-GY/10 y=y+(speedy/upd_speed) EndIf EndMethod Method Shoot() If wait+150<MilliSecs() ShootList.AddLast(PlayerShoot.Create(x,y,shoot_flag)) wait=MilliSecs() EndIf EndMethod Method Bomb() EndMethod Method Draw(cam_posx:Float) SetColor 255,255,255 If x<GX And cam_posx>MAPSIZEX-GX If CollideRect(x+MAPSIZEX-cam_posx,y,PLAYERWIDTH,PLAYERHEIGHT,2,0) SetColor 255,0,255 EndIf If shoot_flag DrawRect x+MAPSIZEX-cam_posx,y,PLAYERWIDTH,PLAYERHEIGHT DrawLine x+MAPSIZEX-cam_posx,y,x+MAPSIZEX-cam_posx,y-5 DrawLine x+MAPSIZEX-cam_posx,y-5,x+MAPSIZEX-cam_posx+PLAYERWIDTH/2,y SetColor 0,0,0 DrawRect (x+MAPSIZEX-cam_posx)+1,y+1,PLAYERWIDTH/2,PLAYERHEIGHT-2 Else DrawRect x+MAPSIZEX-cam_posx,y,PLAYERWIDTH,PLAYERHEIGHT DrawLine x+MAPSIZEX-cam_posx+PLAYERWIDTH-1,y,x+MAPSIZEX-cam_posx+PLAYERWIDTH-1,y-5 DrawLine x+MAPSIZEX-cam_posx+PLAYERWIDTH-1,y-5,x+MAPSIZEX-cam_posx+PLAYERWIDTH/2,y SetColor 0,0,0 DrawRect (x+MAPSIZEX-cam_posx)+PLAYERWIDTH/2-1,y+1,PLAYERWIDTH/2,PLAYERHEIGHT-2 EndIf CollideRect(x+MAPSIZEX-cam_posx,y,PLAYERWIDTH,PLAYERHEIGHT,0,1) SetColor 0,255,255 DrawRect (x+MAPSIZEX-cam_posx)/10+(GX/2-GX/20)-1,GY/12+y/10-1,3,3 ' Anzeige des Raumschiffs im HUD Else If CollideRect(x-cam_posx,y,PLAYERWIDTH,PLAYERHEIGHT,2,0) SetColor 255,0,255 EndIf If shoot_flag DrawRect x-cam_posx,y,PLAYERWIDTH,PLAYERHEIGHT DrawLine x-cam_posx,y,x-cam_posx,y-5 DrawLine x-cam_posx,y-5,x-cam_posx+PLAYERWIDTH/2,y SetColor 0,0,0 DrawRect (x-cam_posx)+1,y+1,PLAYERWIDTH/2,PLAYERHEIGHT-2 Else DrawRect x-cam_posx,y,PLAYERWIDTH,PLAYERHEIGHT DrawLine x-cam_posx+PLAYERWIDTH-1,y,x-cam_posx+PLAYERWIDTH-1,y-5 DrawLine x-cam_posx+PLAYERWIDTH-1,y-5,x-cam_posx+PLAYERWIDTH/2,y SetColor 0,0,0 DrawRect (x-cam_posx)+PLAYERWIDTH/2-1,y+1,PLAYERWIDTH/2,PLAYERHEIGHT-2 EndIf CollideRect(x-cam_posx,y,PLAYERWIDTH,PLAYERHEIGHT,0,1) SetColor 0,255,255 DrawRect (x-cam_posx)/10+(GX/2-GX/20)-1,GY/12+y/10-1,3,3 ' Anzeige des Raumschiffs im HUD EndIf EndMethod Function Create:Player(startx:Float) Local cp:Player=New Player cp.ShootList=New TList cp.x=startx cp.y=GY/2 cp.speedy=6.0 cp.shoot_flag=True cp.stop_flag=True cp.le_ri_flag=cp.shoot_flag cp.up_do_flag=0 ' ToDo am Überlegen wegen Vertikal-Beschleunigung cp.wait=0 Return cp EndFunction EndType Type PlayerShoot Field x:Float Field y:Float Field speed:Float Field shoot_flag:Byte Method Move:Byte(cam_posx:Float,upd_speed:Float) speed=15.0/upd_speed If x<0.0 x=x+MAPSIZEX EndIf If x>MAPSIZEX x=x-MAPSIZEX EndIf If x<GX And cam_posx>MAPSIZEX-GX If shoot_flag If x+PLAYERWIDTH+MAPSIZEX<cam_posx+GX x=x+speed Return True Else Return False EndIf Else If x+MAPSIZEX>cam_posx x=x-speed Return True Else Return False EndIf EndIf Else If shoot_flag If x+PLAYERWIDTH<cam_posx+GX x=x+speed Return True Else Return False EndIf Else If x-speed>cam_posx x=x-speed Return True Else Return False EndIf EndIf EndIf EndMethod Method Draw(cam_posx:Float) SetColor 255,255,0 If x<GX And cam_posx>MAPSIZEX-GX If shoot_flag DrawLine x+PLAYERWIDTH+MAPSIZEX-cam_posx,y,x+PLAYERWIDTH+20+MAPSIZEX-cam_posx,y CollideRect(x+PLAYERWIDTH+MAPSIZEX-cam_posx,y-1,20,3,0,1) Else DrawLine x+MAPSIZEX-cam_posx,y,(x-20)+MAPSIZEX-cam_posx,y CollideRect(x+MAPSIZEX-cam_posx,y-1,-20,3,0,1) EndIf Else If shoot_flag DrawLine x+PLAYERWIDTH-cam_posx,y,x+PLAYERWIDTH+20-cam_posx,y CollideRect(x+PLAYERWIDTH-cam_posx,y-1,20,3,0,1) Else DrawLine x-cam_posx,y,(x-20)-cam_posx,y CollideRect(x-cam_posx,y-1,-20,3,0,1) EndIf EndIf EndMethod Function Create:PlayerShoot(x:Int,y:Int,shoot_flag:Byte) Local ps:PlayerShoot=New PlayerShoot ps.x=x ps.y=y ps.speed=15.0 ps.shoot_flag=shoot_flag Return ps EndFunction EndType Type Enemy Field x:Float Field y:Float Field speedx:Float Field speedy:Float Field changespeedwait:Int Field rtime:Int Method Move(upd_speed:Float) 'Nur zu Testzwecken '------------------------------------ If changespeedwait+rtime<MilliSecs() speedx=Rnd(-1.0,1.0) speedy=Rnd(-1.0,1.0) rtime=Rand(5000,15000) changespeedwait=MilliSecs() EndIf '------------------------------------ x=x+(speedx/upd_speed) y=y+(speedy/upd_speed) If x>MAPSIZEX x=x-MAPSIZEX EndIf If x<0.0 x=x+MAPSIZEX EndIf If y<MAPYNULL-speedy Or y>GY-ENEMYHEIGHT-speedy speedy=-speedy EndIf EndMethod Method Shoot:Byte() Return True EndMethod Method Draw(cam_posx:Float) SetColor 0,255,0 Local xdraw:Float=x-cam_posx If (xdraw<GX And xdraw+ENEMYWIDTH>0) Or (xdraw>-MAPSIZEX And xdraw<-(MAPSIZEX-GX)) If x<GX And cam_posx>MAPSIZEX-GX If CollideRect(xdraw+MAPSIZEX,y,ENEMYWIDTH,ENEMYHEIGHT,1,0) SetColor 255,0,0 EndIf DrawRect xdraw+MAPSIZEX,y,ENEMYWIDTH,ENEMYHEIGHT CollideRect(xdraw+MAPSIZEX,y,ENEMYWIDTH,ENEMYHEIGHT,0,2) Else If CollideRect(xdraw,y,ENEMYWIDTH,ENEMYHEIGHT,1,0) SetColor 255,0,0 EndIf DrawRect xdraw,y,ENEMYWIDTH,ENEMYHEIGHT CollideRect(xdraw,y,ENEMYWIDTH,ENEMYHEIGHT,0,2) EndIf EndIf DrawEnemyOnHUD(x,y,cam_posx) EndMethod Function Create:Enemy() Local ce:Enemy=New Enemy ce.speedx=Rnd(-1.0,1.0) ce.speedy=Rnd(-1.0,1.0) ce.x=Rand(0,MAPSIZEX) ce.y=Rand(MAPYNULL,MAPYNULL+MAPSIZEY-10) ce.changespeedwait=MilliSecs() ce.rtime=5000 Return ce EndFunction EndType Function DrawEnemyOnHUD(x:Float,y:Float,cam_posx:Float) Local xhud:Float=(x+MAPSIZEX/2-GX/2)/10 Local camposxhud:Float=cam_posx/10 If xhud>MAPSIZEX/10 xhud=xhud-MAPSIZEX/10 EndIf If xhud-camposxhud<0 xhud=xhud+MAPSIZEX/10 EndIf SetColor 200,200,200 Plot (xhud-camposxhud)+(GX/2-MAPSIZEX/20),GY/12+y/10 ' Anzeige im HUD EndFunction '------------------------- '--------- ToDo ---------- '------------------------- Type EnemyShoot EndType Type EnemyKI ' Vielleicht reicht da Function() EndType Type PlayerExplosion ' Vielleicht reicht da Function() EndType Type EnemyExplosion EndType '------------------------- '------------------------- Type H_U_D Field x:Int Field y:Int Field wait:Int Field mem:Int Method Draw(Score:Int,Lives:Int,Bombs:Int,cam_posx:Int,px:Int,cs:Float,shootlist:TList,us:Float) SetColor 255,255,255 DrawLine x,y+MAPYNULL,x+GX,y+MAPYNULL DrawLine GX/2-MAPSIZEX/20,y,GX/2-MAPSIZEX/20,MAPYNULL DrawLine GX/2+MAPSIZEX/20,y,GX/2+MAPSIZEX/20,MAPYNULL '--------------------------- DrawLine GX/2-GX/20,GY/12+MAPYNULL/10,GX/2+GX/20,GY/12+MAPYNULL/10 DrawLine GX/2+GX/20,GY/12+MAPYNULL/10,GX/2+GX/20,GY/12+MAPYNULL/10+MAPSIZEY/10 DrawLine GX/2+GX/20,GY/12+MAPYNULL/10+MAPSIZEY/10,GX/2-GX/20,GY/12+MAPYNULL/10+MAPSIZEY/10 DrawLine GX/2-GX/20,GY/12+MAPYNULL/10+MAPSIZEY/10,GX/2-GX/20,GY/12+MAPYNULL/10 '---------------------------- glEnable GL_TEXTURE_2D DrawText "Score: "+Score,130,120 DrawText "Lives: "+Lives,130,132 DrawText "Bombs: "+Bombs,130,144 ' Zum Testzwecken '----------------- DrawText "camposx: "+cam_posx,0,12 DrawText "playerposx: "+px,0,24 DrawText "camspeed: "+cs,0,36 If shootlist=Null DrawText "shoots: "+0,0,48 Else DrawText "shoots: "+CountList(shootlist),0,48 EndIf DrawText "upd_speed: "+us,0,60 If wait+999<MilliSecs() mem=GCMemAlloced() wait=MilliSecs() EndIf DrawText "Speicher: "+mem+" bytes",0,72 glDisable GL_TEXTURE_2D DrawLine 0,90,GX/2-MAPSIZEX/20,90 '----------------- EndMethod Function Create:H_U_D() Local hud:H_U_D=New H_U_D hud.x=0 hud.y=0 hud.wait=MilliSecs() hud.mem=GCMemAlloced() Return hud EndFunction EndType Type Background Field r1:Float Field r2:Float Field r3:Float Field img1:TImage[,] Field img2:TImage[,] Field img3:TImage[,] Field x1:Float[] Field y1:Float[] Field x2:Float[] Field y2:Float[] Field x3:Float[] Field y3:Float[] Method Draw(flag:Byte,cam_speed:Float) If flag r1=-(cam_speed)/10 r2=-(cam_speed)/20 r3=-(cam_speed)/30 Else r1=cam_speed/10 r2=cam_speed/20 r3=cam_speed/30 EndIf '---------------------------- For Local x:Int=0 To STARS_TILES For Local y:Int=0 To STARS_TILES-1 x3[x]=x3[x]+r3 If x3[x]>GX x3[x]=x3[x]-GX-(GX/STARS_TILES) EndIf If x3[x]<-(GX/STARS_TILES) x3[x]=x3[x]+GX+(GX/STARS_TILES) EndIf DrawImage img3[x,y],x3[x],y3[y] Next Next '---------------------------- For Local x:Int=0 To STARS_TILES For Local y:Int=0 To STARS_TILES-1 x2[x]=x2[x]+r2 If x2[x]>GX x2[x]=x2[x]-GX-(GX/STARS_TILES) EndIf If x2[x]<-(GX/STARS_TILES) x2[x]=x2[x]+GX+(GX/STARS_TILES) EndIf DrawImage img2[x,y],x2[x],y2[y] Next Next '---------------------------- For Local x:Int=0 To STARS_TILES For Local y:Int=0 To STARS_TILES-1 x1[x]=x1[x]+r1 If x1[x]>GX x1[x]=x1[x]-GX-(GX/STARS_TILES) EndIf If x1[x]<-(GX/STARS_TILES) x1[x]=x1[x]+GX+(GX/STARS_TILES) EndIf DrawImage img1[x,y],x1[x],y1[y] Next Next EndMethod Function Create:Background() Local bgr:Background=New Background Local x1:Int Local y1:Int Cls '------------------------------- bgr.x1=New Float[STARS_TILES+1] bgr.y1=New Float[STARS_TILES] bgr.img1=New TImage[STARS_TILES+1,STARS_TILES] SetColor 255,255,255 For Local i:Int=0 To STARS_LIMIT1 x1=Rand(0,GX) y1=Rand(MAPYNULL,GY-GY/10) Plot x1,y1 Next Local pluslast:Int=0 For Local x:Int=0 To STARS_TILES For Local y:Int=0 To STARS_TILES-1 Local cimg:TImage=CreateImage(GX/STARS_TILES,MAPSIZEY/STARS_TILES,1,DYNAMICIMAGE|MASKEDIMAGE) If x=STARS_TILES Then pluslast=-GX/2 GrabImage cimg,x*(GX/STARS_TILES)+pluslast,MAPYNULL+y*(MAPSIZEY/STARS_TILES) bgr.img1[x,y]=cimg bgr.x1[x]=x*(GX/STARS_TILES) bgr.y1[y]=MAPYNULL+y*(MAPSIZEY/STARS_TILES) Next Next Cls pluslast=0 '------------------------------- bgr.x2=New Float[STARS_TILES+1] bgr.y2=New Float[STARS_TILES] bgr.img2=New TImage[STARS_TILES+1,STARS_TILES] SetColor 180,180,180 For Local i:Int=0 To STARS_LIMIT2 x1=Rand(0,GX) y1=Rand(MAPYNULL,GY-GY/10) Plot x1,y1 Next For Local x:Int=0 To STARS_TILES For Local y:Int=0 To STARS_TILES-1 Local cimg:TImage=CreateImage(GX/STARS_TILES,MAPSIZEY/STARS_TILES,1,DYNAMICIMAGE|MASKEDIMAGE) If x=STARS_TILES Then pluslast=-GX/2 GrabImage cimg,x*(GX/STARS_TILES)+pluslast,MAPYNULL+y*(MAPSIZEY/STARS_TILES) bgr.img2[x,y]=cimg bgr.x2[x]=x*(GX/STARS_TILES) bgr.y2[y]=MAPYNULL+y*(MAPSIZEY/STARS_TILES) Next Next Cls pluslast=0 '--------------------------------- bgr.x3=New Float[STARS_TILES+1] bgr.y3=New Float[STARS_TILES] bgr.img3=New TImage[STARS_TILES+1,STARS_TILES] SetColor 100,100,100 For Local i:Int=0 To STARS_LIMIT3 x1=Rand(0,GX) y1=Rand(MAPYNULL,GY-GY/10) Plot x1,y1 Next For Local x:Int=0 To STARS_TILES For Local y:Int=0 To STARS_TILES-1 Local cimg:TImage=CreateImage(GX/STARS_TILES,MAPSIZEY/STARS_TILES,1,DYNAMICIMAGE|MASKEDIMAGE) If x=STARS_TILES Then pluslast=-GX/2 GrabImage cimg,x*(GX/STARS_TILES)+pluslast,MAPYNULL+y*(MAPSIZEY/STARS_TILES) bgr.img3[x,y]=cimg bgr.x3[x]=x*(GX/STARS_TILES) bgr.y3[y]=MAPYNULL+y*(MAPSIZEY/STARS_TILES) Next Next Cls '---------------------------------- Return bgr EndFunction EndType Type World Field cam_posx:Float Field cam_speed:Float Field cam_flag:Byte Field cam_stop_value:Float Field cam_max_speed:Float Field _player:Player Field _EnemyList:TList ' ToDo EnemyListe in Enemy-Type reinpacken Field _EnemyShootList:TList Field _background:Background Field _HUD:H_U_D Field PlayerScore:Int Field PlayerLives:Int Field PlayerBombs:Int Field upd_speed:Float Method UpdateWorld(upd_speed:Float) ' ToDo die Steuerung noch richtig anpassen ' ToDo inteligente Kameraverfolgung (Grundgerüst vorhanden) einbauen ResetCollisions(1) _player.stop_flag=True If KeyDown(KEY_LEFT) And Not KeyDown(KEY_RIGHT) _player.shoot_flag=False If _player.le_ri_flag=True And cam_speed>0.0 Else _player.le_ri_flag=False If cam_speed<(cam_max_speed/upd_speed) cam_speed=cam_speed+(0.08/upd_speed) Else cam_speed=(cam_max_speed/upd_speed) EndIf If cam_speed=(cam_max_speed/upd_speed) cam_posx=cam_posx-cam_speed Else cam_posx=cam_posx-cam_speed EndIf If cam_posx<0.0 cam_posx=cam_posx+MAPSIZEX EndIf _player.MoveLeft(cam_speed) EndIf EndIf If KeyDown(KEY_RIGHT) And Not KeyDown(KEY_LEFT) _player.shoot_flag=True If _player.le_ri_flag=False And cam_speed>0.0 Else _player.le_ri_flag=True If cam_speed<(cam_max_speed/upd_speed) cam_speed=cam_speed+(0.08/upd_speed) Else cam_speed=(cam_max_speed/upd_speed) EndIf If cam_speed=(cam_max_speed/upd_speed) cam_posx=cam_posx+cam_speed Else cam_posx=cam_posx+cam_speed EndIf If cam_posx>MAPSIZEX cam_posx=cam_posx-MAPSIZEX EndIf _player.MoveRight(cam_speed) EndIf EndIf If _player.stop_flag ' True = Anhalten If cam_speed=0.0 Else If KeyDown(KEY_RIGHT) Or KeyDown(KEY_LEFT) cam_speed=cam_speed-(0.12/upd_speed) Else cam_speed=cam_speed-(0.04/upd_speed) EndIf If cam_speed<0.0 cam_speed=0.0 EndIf If _player.le_ri_flag cam_posx=cam_posx+cam_speed If cam_posx>MAPSIZEX cam_posx=cam_posx-MAPSIZEX EndIf _player.MoveRight(cam_speed) Else cam_posx=cam_posx-cam_speed If cam_posx<0.0 cam_posx=cam_posx+MAPSIZEX EndIf _player.MoveLeft(cam_speed) EndIf EndIf EndIf If MouseDown(1) _player.Shoot() If MouseHit(2) _player.Bomb() ' ToDo Noch am Überlegen wegen der _player.Bomb Lösung If KeyDown(KEY_UP) _player.MoveUp(upd_speed) If KeyDown(KEY_DOWN) _player.MoveDown(upd_speed) _background.Draw(_player.le_ri_flag,cam_speed) _player.Draw(cam_posx) ResetCollisions(2) For Local ps:PlayerShoot=EachIn _player.ShootList If ps.Move(cam_posx,upd_speed) ps.Draw(cam_posx) Else ListRemove(_player.ShootList,ps) ' ToDo RemoveLink() EndIf Next For Local en:Enemy=EachIn _EnemyList en.Move(upd_speed) en.Draw(cam_posx) Next Rem For ens:EnemyShoot=EachIn _EnemyShootList If ens.Move() ens.Draw() EndIf Next EndRem _HUD.Draw(PlayerScore,PlayerLives,PlayerBombs,cam_posx,_player.x,cam_speed,_player.ShootList,upd_speed) EndMethod Function Create:World() Local cw:World=New World cw.cam_posx=1000.0 ' Startposition der Kamera cw.cam_speed=0.0 cw.cam_max_speed=10.0 ' 10 Pixel bei 85FPS cw.cam_flag=True cw.cam_stop_value=0.04 cw._player=Player.Create(cw.cam_posx+GX/2) ' Startposition des Spielers cw._EnemyList:TList=New TList For Local i:Int=0 To 250 ' Anzahl Enemys cw._EnemyList.AddLast(Enemy.Create()) Next cw._EnemyShootList:TList=New TList cw._background=Background.Create() cw._HUD=H_U_D.Create() cw.PlayerScore=0 cw.PlayerLives=5 cw.PlayerBombs=3 Return cw EndFunction EndType 'Globale Variablen '------------------------------------------ Global Game1:World=World.Create() Global PLAYERWIDTH:Int=40 Global PLAYERHEIGHT:Int=10 Global ENEMYWIDTH:Int=10 Global ENEMYHEIGHT:Int=10 ' HauptSchleife '------------------------------ Local a:Int=MilliSecs() Local fps:Short=0 Local upd_speed:Float=1.0 Local z:Short=0 While Not KeyHit(KEY_ESCAPE) If a+999<MilliSecs() a=MilliSecs() fps=z upd_speed=fps/85.0 z=0 EndIf Cls Game1.UpdateWorld(upd_speed) DrawText "FPS: "+fps,0,0 Flip 0 z=z+1 Wend End MfG LordArtus Edit: Sry , aber ist noch leicht verbuggt , werde es gleich korrigieren. Edit2:Ok , korriegiert , aber verstehe trotzdem nicht , warum es sich so komisch bei FPS-Unterschieden verhält. |
||
Dreamora |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Inwiefern komisch? | ||
Ihr findet die aktuellen Projekte unter Gayasoft und könnt mich unter @gayasoft auf Twitter erreichen. |
![]() |
LordArtus |
![]() Antworten mit Zitat ![]() |
---|---|---|
Als erstes , bewegt sich der Spieler unterschiedlich schnell (rein Visuell) , vorallem die Beschleunigung , je mehr FPS , desto schneller Beschleunigt der Spieler (glaube weiss schon woran das liegt) , aber sollte eigentlich nicht sein.
Zweitens je mehr oder weniger ich den Background aufteile (kann man selber es ausprobieren , einfach STARS_TILES verändern) , ändert sich die Geschwidigkeit der Bewegung von den Background und eigentlich , was hat die Aufteilung mit der Bewegung zu tun ???? MfG LordArtus p.s. Läuft es eigentlich jetzt schneller ? Edit: und noch eine Sache , manchmal passiert es , dass der mir irgenwie Teile von den Desktop , beim Erzeugen des Backgrounds , in den Tiles abspeichert , irgenwie komisch.Wie gesagt es passiert aber ein mal auf 10 starts oder so. |
||
Dreamora |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Das hauptproblem liegt da drin dass du das mit der FPS unabhängigen Programmierung scheinbar nicht ganz verstanden hast.
Was du machst ist fps / desiredFPS Was es aber sein müsste ist desiredFPS / FPS also FPS / 85.0 net umgekehrt, sonst werden die gestraft die zu wenig haben und die die eh schon zuviele FPS haben werden belohnt. |
||
Ihr findet die aktuellen Projekte unter Gayasoft und könnt mich unter @gayasoft auf Twitter erreichen. |
![]() |
LordArtus |
![]() Antworten mit Zitat ![]() |
---|---|---|
Ja aber im Prinzip ist es das Gleiche , ob ich es so schreibe:
upd_speed=fps/85.0 und alles FPS abhängige geteilt durch upd_speed mache , oder so schreibe upd_speed=85.0/fps und alles FPS abhängige mal upd_speed mache. MfG LordArtus p.s. 85.0 weil ich bei 85 FPS alles optimiere. |
||
Dreamora |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Stimmt.
Nur dummerweise machst du es nirgends. Du nutzt die upd Variable eigentlich total falsch. Du schaust ob der speed < max/upd ist anstatt zu schauen ob aktueller speed + veränderung / upd < max ist. Darüber hinaus wird in der hälfte der fälle garnichts gemacht. zb wenns gleich ist dann wird einfach ma minus gerechnet mit einer FPS unabhängigen variable. Bei FPS unabhängiger Programmierung gibt es keine Veränderungen mehr die nicht FPS abhängig sind. |
||
Ihr findet die aktuellen Projekte unter Gayasoft und könnt mich unter @gayasoft auf Twitter erreichen. |
![]() |
LordArtus |
![]() Antworten mit Zitat ![]() |
---|---|---|
ok , habs gefunden , sollte bei jeden jetzt gleich laufen , es war
cam_speed=cam_speed+(0.08/upd_speed) hab erstmal upd_speed=85.0/fps gemacht (gefällt mir besser ![]() und cam_speed=cam_speed+(0.08*upd_speed^2) und etwas die Geschwindigkeiten angepasst , damit es auch wirklich schnell aussieht Code: [AUSKLAPPEN] '--------------------------' '-------- DEFENDER --------.' '---------- 2007 ----------.' '--------------------------.' '-- Remake -by LordArtus --.' '--------------------------.' '...........................' 'Ver.Alpha 0.5 '------------- SuperStrict SeedRnd MilliSecs() SetGraphicsDriver GLMax2DDriver() 'ToDo genaue Überprüfung des Spiels bei Auflösungswechsel und wie es auf FPS-Unterschiede reagiert Const GX:Int=1024 Const GY:Int=768 Const MAPSIZEX:Float=5120.0 Const MAPSIZEY:Int=GY-GY/5 Const MAPYNULL:Int=GY/5 Const STARS_LIMIT1:Int=500 Const STARS_LIMIT2:Int=1000 Const STARS_LIMIT3:Int=1500 Const STARS_TILES:Int=6 ' 10 bedeutet Background wird auf 10*10 geteilt(100 Tiles) Graphics GX,GY,32 ' Types und Funktionen '---------------------- Type Player Field x:Float Field y:Float Field speedx:Float Field speedy:Float Field le_ri_flag:Byte Field up_do_flag:Byte Field shoot_flag:Byte Field stop_flag:Byte Field ShootList:TList Field wait:Int Method MoveLeft(cam_speed:Float) speedx=cam_speed x=x-speedx If x<0.0 x=x+MAPSIZEX EndIf stop_flag=False EndMethod Method MoveRight(cam_speed:Float) speedx=cam_speed x=x+speedx If x>MAPSIZEX x=x-MAPSIZEX EndIf stop_flag=False EndMethod Method MoveUp(upd_speed:Float) If y>MAPYNULL+7 y=y-(speedy*upd_speed) EndIf EndMethod Method MoveDown(upd_speed:Float) If y<GY-GY/10 y=y+(speedy*upd_speed) EndIf EndMethod Method Shoot() If wait+150<MilliSecs() ShootList.AddLast(PlayerShoot.Create(x,y,shoot_flag)) wait=MilliSecs() EndIf EndMethod Method Bomb() EndMethod Method Draw(cam_posx:Float) SetColor 255,255,255 If x<GX And cam_posx>MAPSIZEX-GX If CollideRect(x+MAPSIZEX-cam_posx,y,PLAYERWIDTH,PLAYERHEIGHT,2,0) SetColor 255,0,255 EndIf If shoot_flag DrawRect x+MAPSIZEX-cam_posx,y,PLAYERWIDTH,PLAYERHEIGHT DrawLine x+MAPSIZEX-cam_posx,y,x+MAPSIZEX-cam_posx,y-5 DrawLine x+MAPSIZEX-cam_posx,y-5,x+MAPSIZEX-cam_posx+PLAYERWIDTH/2,y SetColor 0,0,0 DrawRect (x+MAPSIZEX-cam_posx)+1,y+1,PLAYERWIDTH/2,PLAYERHEIGHT-2 Else DrawRect x+MAPSIZEX-cam_posx,y,PLAYERWIDTH,PLAYERHEIGHT DrawLine x+MAPSIZEX-cam_posx+PLAYERWIDTH-1,y,x+MAPSIZEX-cam_posx+PLAYERWIDTH-1,y-5 DrawLine x+MAPSIZEX-cam_posx+PLAYERWIDTH-1,y-5,x+MAPSIZEX-cam_posx+PLAYERWIDTH/2,y SetColor 0,0,0 DrawRect (x+MAPSIZEX-cam_posx)+PLAYERWIDTH/2-1,y+1,PLAYERWIDTH/2,PLAYERHEIGHT-2 EndIf CollideRect(x+MAPSIZEX-cam_posx,y,PLAYERWIDTH,PLAYERHEIGHT,0,1) SetColor 0,255,255 DrawRect (x+MAPSIZEX-cam_posx)/10+(GX/2-GX/20)-1,GY/12+y/10-1,3,3 ' Anzeige des Raumschiffs im HUD Else If CollideRect(x-cam_posx,y,PLAYERWIDTH,PLAYERHEIGHT,2,0) SetColor 255,0,255 EndIf If shoot_flag DrawRect x-cam_posx,y,PLAYERWIDTH,PLAYERHEIGHT DrawLine x-cam_posx,y,x-cam_posx,y-5 DrawLine x-cam_posx,y-5,x-cam_posx+PLAYERWIDTH/2,y SetColor 0,0,0 DrawRect (x-cam_posx)+1,y+1,PLAYERWIDTH/2,PLAYERHEIGHT-2 Else DrawRect x-cam_posx,y,PLAYERWIDTH,PLAYERHEIGHT DrawLine x-cam_posx+PLAYERWIDTH-1,y,x-cam_posx+PLAYERWIDTH-1,y-5 DrawLine x-cam_posx+PLAYERWIDTH-1,y-5,x-cam_posx+PLAYERWIDTH/2,y SetColor 0,0,0 DrawRect (x-cam_posx)+PLAYERWIDTH/2-1,y+1,PLAYERWIDTH/2,PLAYERHEIGHT-2 EndIf CollideRect(x-cam_posx,y,PLAYERWIDTH,PLAYERHEIGHT,0,1) SetColor 0,255,255 DrawRect (x-cam_posx)/10+(GX/2-GX/20)-1,GY/12+y/10-1,3,3 ' Anzeige des Raumschiffs im HUD EndIf EndMethod Function Create:Player(startx:Float) Local cp:Player=New Player cp.ShootList=New TList cp.x=startx cp.y=GY/2 cp.speedy=6.0 cp.shoot_flag=True cp.stop_flag=True cp.le_ri_flag=cp.shoot_flag cp.up_do_flag=0 ' ToDo am Überlegen wegen Vertikal-Beschleunigung cp.wait=0 Return cp EndFunction EndType Type PlayerShoot Field x:Float Field y:Float Field speed:Float Field shoot_flag:Byte Method Move:Byte(cam_posx:Float,upd_speed:Float) speed=20.0*upd_speed If x<0.0 x=x+MAPSIZEX EndIf If x>MAPSIZEX x=x-MAPSIZEX EndIf If x<GX And cam_posx>MAPSIZEX-GX If shoot_flag If x+PLAYERWIDTH+MAPSIZEX<cam_posx+GX x=x+speed Return True Else Return False EndIf Else If x+MAPSIZEX>cam_posx x=x-speed Return True Else Return False EndIf EndIf Else If shoot_flag If x+PLAYERWIDTH<cam_posx+GX x=x+speed Return True Else Return False EndIf Else If x-speed>cam_posx x=x-speed Return True Else Return False EndIf EndIf EndIf EndMethod Method Draw(cam_posx:Float) SetColor 255,255,0 If x<GX And cam_posx>MAPSIZEX-GX If shoot_flag DrawLine x+PLAYERWIDTH+MAPSIZEX-cam_posx,y,x+PLAYERWIDTH+20+MAPSIZEX-cam_posx,y CollideRect(x+PLAYERWIDTH+MAPSIZEX-cam_posx,y-1,20,3,0,1) Else DrawLine x+MAPSIZEX-cam_posx,y,(x-20)+MAPSIZEX-cam_posx,y CollideRect(x+MAPSIZEX-cam_posx,y-1,-20,3,0,1) EndIf Else If shoot_flag DrawLine x+PLAYERWIDTH-cam_posx,y,x+PLAYERWIDTH+20-cam_posx,y CollideRect(x+PLAYERWIDTH-cam_posx,y-1,20,3,0,1) Else DrawLine x-cam_posx,y,(x-20)-cam_posx,y CollideRect(x-cam_posx,y-1,-20,3,0,1) EndIf EndIf EndMethod Function Create:PlayerShoot(x:Int,y:Int,shoot_flag:Byte) Local ps:PlayerShoot=New PlayerShoot ps.x=x ps.y=y ps.speed=20.0 ps.shoot_flag=shoot_flag Return ps EndFunction EndType Type Enemy Field x:Float Field y:Float Field speedx:Float Field speedy:Float Field changespeedwait:Int Field rtime:Int Method Move(upd_speed:Float) 'Nur zu Testzwecken '------------------------------------ If changespeedwait+rtime<MilliSecs() speedx=Rnd(-1.0,1.0) speedy=Rnd(-1.0,1.0) rtime=Rand(5000,15000) changespeedwait=MilliSecs() EndIf '------------------------------------ x=x+(speedx*upd_speed) y=y+(speedy*upd_speed) If x>MAPSIZEX x=x-MAPSIZEX EndIf If x<0.0 x=x+MAPSIZEX EndIf If y<MAPYNULL-speedy Or y>GY-ENEMYHEIGHT-speedy speedy=-speedy EndIf EndMethod Method Shoot:Byte() Return True EndMethod Method Draw(cam_posx:Float) SetColor 0,255,0 Local xdraw:Float=x-cam_posx If (xdraw<GX And xdraw+ENEMYWIDTH>0) Or (xdraw>-MAPSIZEX And xdraw<-(MAPSIZEX-GX)) If x<GX And cam_posx>MAPSIZEX-GX If CollideRect(xdraw+MAPSIZEX,y,ENEMYWIDTH,ENEMYHEIGHT,1,0) SetColor 255,0,0 EndIf DrawRect xdraw+MAPSIZEX,y,ENEMYWIDTH,ENEMYHEIGHT CollideRect(xdraw+MAPSIZEX,y,ENEMYWIDTH,ENEMYHEIGHT,0,2) Else If CollideRect(xdraw,y,ENEMYWIDTH,ENEMYHEIGHT,1,0) SetColor 255,0,0 EndIf DrawRect xdraw,y,ENEMYWIDTH,ENEMYHEIGHT CollideRect(xdraw,y,ENEMYWIDTH,ENEMYHEIGHT,0,2) EndIf EndIf DrawEnemyOnHUD(x,y,cam_posx) EndMethod Function Create:Enemy() Local ce:Enemy=New Enemy ce.speedx=Rnd(-1.0,1.0) ce.speedy=Rnd(-1.0,1.0) ce.x=Rand(0,MAPSIZEX) ce.y=Rand(MAPYNULL,MAPYNULL+MAPSIZEY-10) ce.changespeedwait=MilliSecs() ce.rtime=5000 Return ce EndFunction EndType Function DrawEnemyOnHUD(x:Float,y:Float,cam_posx:Float) Local xhud:Float=(x+MAPSIZEX/2-GX/2)/10 Local camposxhud:Float=cam_posx/10 If xhud>MAPSIZEX/10 xhud=xhud-MAPSIZEX/10 EndIf If xhud-camposxhud<0 xhud=xhud+MAPSIZEX/10 EndIf SetColor 200,200,200 Plot (xhud-camposxhud)+(GX/2-MAPSIZEX/20),GY/12+y/10 ' Anzeige im HUD EndFunction '------------------------- '--------- ToDo ---------- '------------------------- Type EnemyShoot EndType Type EnemyKI ' Vielleicht reicht da Function() EndType Type PlayerExplosion ' Vielleicht reicht da Function() EndType Type EnemyExplosion EndType '------------------------- '------------------------- Type H_U_D Field x:Int Field y:Int Field wait:Int Field mem:Int Method Draw(Score:Int,Lives:Int,Bombs:Int,cam_posx:Int,px:Int,cs:Float,shootlist:TList,us:Float) SetColor 255,255,255 DrawLine x,y+MAPYNULL,x+GX,y+MAPYNULL DrawLine GX/2-MAPSIZEX/20,y,GX/2-MAPSIZEX/20,MAPYNULL DrawLine GX/2+MAPSIZEX/20,y,GX/2+MAPSIZEX/20,MAPYNULL '--------------------------- DrawLine GX/2-GX/20,GY/12+MAPYNULL/10,GX/2+GX/20,GY/12+MAPYNULL/10 DrawLine GX/2+GX/20,GY/12+MAPYNULL/10,GX/2+GX/20,GY/12+MAPYNULL/10+MAPSIZEY/10 DrawLine GX/2+GX/20,GY/12+MAPYNULL/10+MAPSIZEY/10,GX/2-GX/20,GY/12+MAPYNULL/10+MAPSIZEY/10 DrawLine GX/2-GX/20,GY/12+MAPYNULL/10+MAPSIZEY/10,GX/2-GX/20,GY/12+MAPYNULL/10 '---------------------------- glEnable GL_TEXTURE_2D DrawText "Score: "+Score,130,120 DrawText "Lives: "+Lives,130,132 DrawText "Bombs: "+Bombs,130,144 ' Zum Testzwecken '----------------- DrawText "camposx: "+cam_posx,0,12 DrawText "playerposx: "+px,0,24 DrawText "camspeed: "+cs,0,36 If shootlist=Null DrawText "shoots: "+0,0,48 Else DrawText "shoots: "+CountList(shootlist),0,48 EndIf DrawText "upd_speed: "+us,0,60 If wait+999<MilliSecs() mem=GCMemAlloced() wait=MilliSecs() EndIf DrawText "Speicher: "+mem+" bytes",0,72 glDisable GL_TEXTURE_2D DrawLine 0,90,GX/2-MAPSIZEX/20,90 '----------------- EndMethod Function Create:H_U_D() Local hud:H_U_D=New H_U_D hud.x=0 hud.y=0 hud.wait=MilliSecs() hud.mem=GCMemAlloced() Return hud EndFunction EndType Type Background Field r1:Float Field r2:Float Field r3:Float Field img1:TImage[,] Field img2:TImage[,] Field img3:TImage[,] Field x1:Float[] Field y1:Float[] Field x2:Float[] Field y2:Float[] Field x3:Float[] Field y3:Float[] Method Draw(flag:Byte,cam_speed:Float) If flag r1=-(cam_speed)/10 r2=-(cam_speed)/20 r3=-(cam_speed)/30 Else r1=cam_speed/10 r2=cam_speed/20 r3=cam_speed/30 EndIf '---------------------------- For Local x:Int=0 To STARS_TILES For Local y:Int=0 To STARS_TILES-1 x3[x]=x3[x]+r3 If x3[x]>GX x3[x]=x3[x]-GX-(GX/STARS_TILES) EndIf If x3[x]<-(GX/STARS_TILES) x3[x]=x3[x]+GX+(GX/STARS_TILES) EndIf DrawImage img3[x,y],x3[x],y3[y] Next Next '---------------------------- For Local x:Int=0 To STARS_TILES For Local y:Int=0 To STARS_TILES-1 x2[x]=x2[x]+r2 If x2[x]>GX x2[x]=x2[x]-GX-(GX/STARS_TILES) EndIf If x2[x]<-(GX/STARS_TILES) x2[x]=x2[x]+GX+(GX/STARS_TILES) EndIf DrawImage img2[x,y],x2[x],y2[y] Next Next '---------------------------- For Local x:Int=0 To STARS_TILES For Local y:Int=0 To STARS_TILES-1 x1[x]=x1[x]+r1 If x1[x]>GX x1[x]=x1[x]-GX-(GX/STARS_TILES) EndIf If x1[x]<-(GX/STARS_TILES) x1[x]=x1[x]+GX+(GX/STARS_TILES) EndIf DrawImage img1[x,y],x1[x],y1[y] Next Next EndMethod Function Create:Background() Local bgr:Background=New Background Local x1:Int Local y1:Int Cls '------------------------------- bgr.x1=New Float[STARS_TILES+1] bgr.y1=New Float[STARS_TILES] bgr.img1=New TImage[STARS_TILES+1,STARS_TILES] SetColor 255,255,255 For Local i:Int=0 To STARS_LIMIT1 x1=Rand(0,GX) y1=Rand(MAPYNULL,GY-GY/10) Plot x1,y1 Next Local pluslast:Int=0 For Local x:Int=0 To STARS_TILES For Local y:Int=0 To STARS_TILES-1 Local cimg:TImage=CreateImage(GX/STARS_TILES,MAPSIZEY/STARS_TILES,1,DYNAMICIMAGE|MASKEDIMAGE) If x=STARS_TILES Then pluslast=-GX/2 GrabImage cimg,x*(GX/STARS_TILES)+pluslast,MAPYNULL+y*(MAPSIZEY/STARS_TILES) bgr.img1[x,y]=cimg bgr.x1[x]=x*(GX/STARS_TILES) bgr.y1[y]=MAPYNULL+y*(MAPSIZEY/STARS_TILES) Next Next Cls pluslast=0 '------------------------------- bgr.x2=New Float[STARS_TILES+1] bgr.y2=New Float[STARS_TILES] bgr.img2=New TImage[STARS_TILES+1,STARS_TILES] SetColor 180,180,180 For Local i:Int=0 To STARS_LIMIT2 x1=Rand(0,GX) y1=Rand(MAPYNULL,GY-GY/10) Plot x1,y1 Next For Local x:Int=0 To STARS_TILES For Local y:Int=0 To STARS_TILES-1 Local cimg:TImage=CreateImage(GX/STARS_TILES,MAPSIZEY/STARS_TILES,1,DYNAMICIMAGE|MASKEDIMAGE) If x=STARS_TILES Then pluslast=-GX/2 GrabImage cimg,x*(GX/STARS_TILES)+pluslast,MAPYNULL+y*(MAPSIZEY/STARS_TILES) bgr.img2[x,y]=cimg bgr.x2[x]=x*(GX/STARS_TILES) bgr.y2[y]=MAPYNULL+y*(MAPSIZEY/STARS_TILES) Next Next Cls pluslast=0 '--------------------------------- bgr.x3=New Float[STARS_TILES+1] bgr.y3=New Float[STARS_TILES] bgr.img3=New TImage[STARS_TILES+1,STARS_TILES] SetColor 100,100,100 For Local i:Int=0 To STARS_LIMIT3 x1=Rand(0,GX) y1=Rand(MAPYNULL,GY-GY/10) Plot x1,y1 Next For Local x:Int=0 To STARS_TILES For Local y:Int=0 To STARS_TILES-1 Local cimg:TImage=CreateImage(GX/STARS_TILES,MAPSIZEY/STARS_TILES,1,DYNAMICIMAGE|MASKEDIMAGE) If x=STARS_TILES Then pluslast=-GX/2 GrabImage cimg,x*(GX/STARS_TILES)+pluslast,MAPYNULL+y*(MAPSIZEY/STARS_TILES) bgr.img3[x,y]=cimg bgr.x3[x]=x*(GX/STARS_TILES) bgr.y3[y]=MAPYNULL+y*(MAPSIZEY/STARS_TILES) Next Next Cls '---------------------------------- Return bgr EndFunction EndType Type World Field cam_posx:Float Field cam_speed:Double Field cam_flag:Byte Field cam_stop_value:Float Field cam_max_speed:Float Field _player:Player Field _EnemyList:TList ' ToDo EnemyListe in Enemy-Type reinpacken Field _EnemyShootList:TList Field _background:Background Field _HUD:H_U_D Field PlayerScore:Int Field PlayerLives:Int Field PlayerBombs:Int Field upd_speed:Double Method UpdateWorld(upd_speed:Double) ' ToDo die Steuerung noch richtig anpassen ' ToDo inteligente Kameraverfolgung (Grundgerüst vorhanden) einbauen ResetCollisions(1) _player.stop_flag=True If KeyDown(KEY_LEFT) And Not KeyDown(KEY_RIGHT) _player.shoot_flag=False If _player.le_ri_flag=True And cam_speed>0.0 Else _player.le_ri_flag=False If cam_speed<(cam_max_speed*upd_speed) cam_speed=cam_speed+(0.1*(upd_speed^2)) Else cam_speed=(cam_max_speed*upd_speed) EndIf If cam_speed=(cam_max_speed*upd_speed) cam_posx=cam_posx-cam_speed Else cam_posx=cam_posx-cam_speed EndIf If cam_posx<0.0 cam_posx=cam_posx+MAPSIZEX EndIf _player.MoveLeft(cam_speed) EndIf EndIf If KeyDown(KEY_RIGHT) And Not KeyDown(KEY_LEFT) _player.shoot_flag=True If _player.le_ri_flag=False And cam_speed>0.0 Else _player.le_ri_flag=True If cam_speed<(cam_max_speed*upd_speed) cam_speed=cam_speed+(0.1*(upd_speed^2)) Else cam_speed=(cam_max_speed*upd_speed) EndIf If cam_speed=(cam_max_speed*upd_speed) cam_posx=cam_posx+cam_speed Else cam_posx=cam_posx+cam_speed EndIf If cam_posx>MAPSIZEX cam_posx=cam_posx-MAPSIZEX EndIf _player.MoveRight(cam_speed) EndIf EndIf If _player.stop_flag ' True = Anhalten If cam_speed=0.0 Else If KeyDown(KEY_RIGHT) Or KeyDown(KEY_LEFT) cam_speed=cam_speed-(0.15*(upd_speed^2)) Else cam_speed=cam_speed-(0.05*(upd_speed^2)) EndIf If cam_speed<0.0 cam_speed=0.0 EndIf If _player.le_ri_flag cam_posx=cam_posx+cam_speed If cam_posx>MAPSIZEX cam_posx=cam_posx-MAPSIZEX EndIf _player.MoveRight(cam_speed) Else cam_posx=cam_posx-cam_speed If cam_posx<0.0 cam_posx=cam_posx+MAPSIZEX EndIf _player.MoveLeft(cam_speed) EndIf EndIf EndIf If MouseDown(1) _player.Shoot() If MouseHit(2) _player.Bomb() ' ToDo Noch am Überlegen wegen der _player.Bomb Lösung If KeyDown(KEY_UP) _player.MoveUp(upd_speed) If KeyDown(KEY_DOWN) _player.MoveDown(upd_speed) _background.Draw(_player.le_ri_flag,cam_speed) _player.Draw(cam_posx) ResetCollisions(2) For Local ps:PlayerShoot=EachIn _player.ShootList If ps.Move(cam_posx,upd_speed) ps.Draw(cam_posx) Else ListRemove(_player.ShootList,ps) ' ToDo RemoveLink() EndIf Next For Local en:Enemy=EachIn _EnemyList en.Move(upd_speed) en.Draw(cam_posx) Next Rem For ens:EnemyShoot=EachIn _EnemyShootList If ens.Move() ens.Draw() EndIf Next EndRem _HUD.Draw(PlayerScore,PlayerLives,PlayerBombs,cam_posx,_player.x,cam_speed,_player.ShootList,upd_speed) EndMethod Function Create:World() Local cw:World=New World cw.cam_posx=1000.0 ' Startposition der Kamera cw.cam_speed=0.0 cw.cam_max_speed=15.0 ' 10 Pixel bei 85FPS cw.cam_flag=True cw.cam_stop_value=0.04 cw._player=Player.Create(cw.cam_posx+GX/2) ' Startposition des Spielers cw._EnemyList:TList=New TList For Local i:Int=0 To 250 ' Anzahl Enemys cw._EnemyList.AddLast(Enemy.Create()) Next cw._EnemyShootList:TList=New TList cw._background=Background.Create() cw._HUD=H_U_D.Create() cw.PlayerScore=0 cw.PlayerLives=5 cw.PlayerBombs=3 Return cw EndFunction EndType 'Globale Variablen '------------------------------------------ Global Game1:World=World.Create() Global PLAYERWIDTH:Int=40 Global PLAYERHEIGHT:Int=10 Global ENEMYWIDTH:Int=10 Global ENEMYHEIGHT:Int=10 ' HauptSchleife '------------------------------ Local a:Int=MilliSecs() Local fps:Short=0 Local upd_speed:Double=1.0 Local z:Short=0 While Not KeyHit(KEY_ESCAPE) If a+999<MilliSecs() a=MilliSecs() fps=z upd_speed=85.0/fps z=0 EndIf Cls Game1.UpdateWorld(upd_speed) DrawText "FPS: "+fps,0,0 Flip 1 z=z+1 Wend End MfG LordArtus p.s. wegen Auflösungswechsels muss ich noch alles anpassen , aber FPS unabhängig sollte es eigentlich jetzt schon sein. Edit: Und hoffe , es läuft schneller als am Anfang.Und nochmals möchte ich mich bei Denen bedanken , die mir die FPS gepostet haben. |
||
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group