Autor Beitrag
klezmor
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 558


delphi 6 personal delphi 2005 personal
BeitragVerfasst: So 04.03.07 13:11 
In meinem snakeähnlichen Spiel verwende ich den normalen Timer als Gameloop, dieser ist allerdings glaube ich ungenau und langsam.
Jetzt frage ich mich natürlich, ob es eine bessere Lösung gibt.
Ich habe schon gesucht, aber nichts passendes gefunden.
Diese Gameloop sollte möglichst genau sein und vom Computer unabhängig sein, bzw. CPU.
Die Tastaturabfrage sollte auch in dieser gameloop stattfinden. Verwende da am besten getasynkey() oder?

Noch eine frage bezüglich es spiels ich habe eine TImage Komponente, auf deren Canvas ich zeichne und aus lese: canvas.moveto/lineto und das auslesen geht so if (image.canvas.pixels[bla,blub]>0) then ... --> geht das auch noch effektiver?

_________________
"Beware of bugs in the above code; I have only proved it correct, not tried it." Donald Knuth
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: So 04.03.07 13:19 
Statt Canvas.Pixels kannst du vlt. auch Image.Bitmap.Scanline nehmen. Das arbeitet schneller.

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
klezmor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 558


delphi 6 personal delphi 2005 personal
BeitragVerfasst: So 04.03.07 13:26 
ja aber image.canvas und image.bitmap sind ja lzwei unterschiedliche sachen.

_________________
"Beware of bugs in the above code; I have only proved it correct, not tried it." Donald Knuth
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: So 04.03.07 13:41 
Zum 1.: Application.OnIdle und TimebasedMovement.
Zum 2.: Nein, das ist nichts anderes ;-).

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
klezmor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 558


delphi 6 personal delphi 2005 personal
BeitragVerfasst: So 04.03.07 14:01 
leider habe ich nichts passendes gefunden.
Habe mal eine endlosschleife mit application.processmessages gemacht, aber das ist dann voll langsam.

_________________
"Beware of bugs in the above code; I have only proved it correct, not tried it." Donald Knuth
Jakob_Ullmann
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1747
Erhaltene Danke: 15

Win 7, *Ubuntu GNU/Linux*
*Anjuta* (C, C++, Python), Geany (Vala), Lazarus (Pascal), Eclipse (Java)
BeitragVerfasst: So 04.03.07 14:36 
In DelphiX gibt es TDXTimer.
Der ist glaube ich ein bisschen genauer.
Du kannst aber auch einen unsichtbaren TDayTimePicker (glaube, so heißt der) ins Formular setzen.
Dann kannst du in einer Funktion kontrollieren, ob der Abstant der Zeit zur vorherigen deinem TTimer.Interval entspricht. Und als Keyboardabfrage würde ich auch GetAsyncKeyState (oder wie auch immer) verwenden.
Ich würde allerdings grundsätzlich TDXDraw aus DelphiX verwenden (falls du die hast).
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: So 04.03.07 16:58 
klezmor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 558


delphi 6 personal delphi 2005 personal
BeitragVerfasst: So 04.03.07 17:29 
Ich möchte allerdings weder eine engine in mein projekt einbauen, noch die für meinen Gebrauch viel zu komplexe Opengl-lib einbauen. Delphi x ist auch nicht mein Fall.
Habe jetzt einmal das ganze mit application.idle gemacht, allerdings ist diese routine noch langsamer als mein onehin langsamer timer. :( :(

_________________
"Beware of bugs in the above code; I have only proved it correct, not tried it." Donald Knuth
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: So 04.03.07 18:52 
lies dir das durch, dann weißt du wie das geht, mir ging es bei den links nicht um opengl, sondern das erste beispiel zeigt die implementierung von onidle, das zweite zeigt das dafür notwendige timebased movement und im dritten link findest du den source. noch einfacher kann man es eigentlich nicht mehr haben.

mfg
klezmor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 558


delphi 6 personal delphi 2005 personal
BeitragVerfasst: So 04.03.07 19:48 
Ok werd ich machen, war nur anfangs irritiert, weil das onidle bei mir langsamer als mein timer war.

_________________
"Beware of bugs in the above code; I have only proved it correct, not tried it." Donald Knuth
klezmor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 558


delphi 6 personal delphi 2005 personal
BeitragVerfasst: Mo 05.03.07 20:16 
Falls jetzt zufällig ein Beispiel für eine Gameloop in Form von Code hat, der kann dieses natürlich auch posten.

_________________
"Beware of bugs in the above code; I have only proved it correct, not tried it." Donald Knuth