GPWiki.org
GPWiki.org
It is currently Sat May 25, 2013 10:58 am

All times are UTC




Post new topic Reply to topic  [ 76 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
PostPosted: Sat Apr 07, 2012 6:11 pm 
Source Code Swashbuckler
User avatar

Joined: Wed Nov 09, 2011 3:58 am
Posts: 199
Location: Brazil
Can anyone help me with this main loop? I did it according to the tutorial that I posted before, but I'm not 100% secure. Also, I'm showing the framerate in the window title, but it's showing 31, instead of the expected 30.
Image

You can see the code here:
Spoiler: show
Code:
  BFrames := 0;
  BTimeSkip := 1000 div FFrameRate;
  BTime := GetTickCount;
  BTimeNext := GetTickCount;
  BSecCounter := 0;
 
  while (Self.FApplicationGameRunning = True) do
  begin
    BTime := GetTickCount;

    Self.ProcessMessages;
    Self.ProcessRender;

    BTimeNext := BTimeNext + BTimeSkip;
    BTimeDifference := BTimeNext - GetTickCount;
    if (BTimeDifference >= 0) then
    begin
      Sleep(BTimeDifference);
    end else
    begin
      // The processing is behind; Let it go faster;
    end;

    if (BSecCounter >= 1000) then
    begin
      Self.FForm.Caption := 'FrameRate[' + IntToStr(BFrames) + ']';
      BFrames := 0;
      BSecCounter := 0;
    end;
    BFrames := BFrames + 1;
    BTimingCounter := BTimingCounter + BTimeDifference;
  end;
 

_________________
"Life finds a way." - Ian Malcolm
My WebBlog: PixelDeveloper
English is not my native language, so excuse me for any writing mistakes.


Top
 Profile  
 
PostPosted: Sat Apr 07, 2012 8:27 pm 
Bytewise

Joined: Sun Oct 16, 2011 3:09 pm
Posts: 277
Location: Here (where else?)
Quote:
BTimeSkip := 1000 div FFrameRate;
The most likely thing I can find is this. Assuming everything is an integer, your value may get rounded down, so you wait slightly too short, and you get more frames than you expect.

Not sure how much you should try to really get 30. I'd be happy with 29 or 31.

It may not even be possible to get exactly 30, as you have to wait 33.33333333333333333333333333 milliseconds (I forgot infinitely many 3s at the end, but you get the idea :) ) then, which is an awkward value.

20 frames of 25 frames should be easier, as the 'div' works nicely with those values.


(In my project, I have the reverse problem, I wait 30 milliseconds, so my framerate is a very weird number :p ).

_________________
My project: Messing about in FreeRCT, dev blog, and IRC #freerct at oftc.net


Top
 Profile  
 
PostPosted: Sun Apr 08, 2012 5:40 pm 
Source Code Swashbuckler
User avatar

Joined: Wed Nov 09, 2011 3:58 am
Posts: 199
Location: Brazil
Thank you! I think you are right. :)

_________________
"Life finds a way." - Ian Malcolm
My WebBlog: PixelDeveloper
English is not my native language, so excuse me for any writing mistakes.


Top
 Profile  
 
PostPosted: Thu May 17, 2012 9:09 pm 
Source Code Swashbuckler
User avatar

Joined: Wed Nov 09, 2011 3:58 am
Posts: 199
Location: Brazil
Boys and Girls, now Machina Engine is able to use sprites!!!!!!

Little fish inspired in E.V.O.:
Image
:rock Yeah, baby!
Most of the updates I'm posting on my blog: http://pixeldeveloper.blogspot.com.br/

Well, I was very surprised... all the process(initialize the main class, load data files, parser them, load rooms/maps inside them, load the objects inside the maps, load resource files, and load all sprites from the resource files) took only 93 milliseconds. Very fast.

This weekend will be exciting!

_________________
"Life finds a way." - Ian Malcolm
My WebBlog: PixelDeveloper
English is not my native language, so excuse me for any writing mistakes.


Top
 Profile  
 
PostPosted: Fri May 18, 2012 8:05 pm 
Bibliotherapist
User avatar

Joined: Wed Nov 03, 2004 1:28 pm
Posts: 6719
Location: Oxford, Englandshire
Nice to see this moving forward. Keep it up. 8)

_________________
10 PRINT "Bad Monkey ";
20 GOTO 10


Top
 Profile  
 
PostPosted: Sat May 19, 2012 8:46 pm 
Source Code Swashbuckler
User avatar

Joined: Wed Nov 09, 2011 3:58 am
Posts: 199
Location: Brazil
My first video showing a small example:

http://youtu.be/YDKMPhkKHgM

The movement in the video is flickering a bit, but it is actually very smooth :yeah

_________________
"Life finds a way." - Ian Malcolm
My WebBlog: PixelDeveloper
English is not my native language, so excuse me for any writing mistakes.


Top
 Profile  
 
PostPosted: Sat May 19, 2012 9:15 pm 
Bytewise

Joined: Sun Oct 16, 2011 3:09 pm
Posts: 277
Location: Here (where else?)
Looking great!

_________________
My project: Messing about in FreeRCT, dev blog, and IRC #freerct at oftc.net


Top
 Profile  
 
PostPosted: Sun Jun 10, 2012 9:42 pm 
Source Code Swashbuckler
User avatar

Joined: Wed Nov 09, 2011 3:58 am
Posts: 199
Location: Brazil
I got a little stucked in recent days. I started to re-write the code to use XML as data files(Yeah, I envied Alberth :rofl ). I'm almost done with this conversion, and I am happy that the result has been positive. Using my parser, the code was less flexible and slower to load. To give you an idea, the same test that I have shown above now varies between 30-72 milliseconds to load. :rock
Looks little bit, but with a big data file these milliseconds could change to big amount of seconds.

_________________
"Life finds a way." - Ian Malcolm
My WebBlog: PixelDeveloper
English is not my native language, so excuse me for any writing mistakes.


Top
 Profile  
 
PostPosted: Mon Jun 11, 2012 4:35 am 
Bytewise

Joined: Sun Oct 16, 2011 3:09 pm
Posts: 277
Location: Here (where else?)
FelipeFS wrote:
I got a little stucked in recent days. I started to re-write the code to use XML as data files(Yeah, I envied Alberth :rofl ).
No need for envy, just copy approaches that work :D

FelipeFS wrote:
I'm almost done with this conversion, and I am happy that the result has been positive. Using my parser, the code was less flexible and slower to load. To give you an idea, the same test that I have shown above now varies between 30-72 milliseconds to load. :rock
Looks little bit, but with a big data file these milliseconds could change to big amount of seconds.
I think the key-phrase here is 'more flexible'. Parser speedup is nice until you go below the data-transfer limit of the hard-disk, then it's totally irrelevant (since you cannot parse data faster than it is coming in from the disk).

Nonetheless, a factor 2 is quite good :)

_________________
My project: Messing about in FreeRCT, dev blog, and IRC #freerct at oftc.net


Top
 Profile  
 
PostPosted: Mon Jun 11, 2012 9:12 am 
Source Code Swashbuckler
User avatar

Joined: Wed Nov 09, 2011 3:58 am
Posts: 199
Location: Brazil
Pheeeeeeeeeeeww... All night working, and the code was fully adapted to XML.

Unfornately, my game engine will work only for Free Pascal for a while, because Delphi uses a different library for XML parsing, and booth of the libraries(the on used by Free Pascal, and the one used by Delphi) are very hard to make work in booth IDEs.

THIS TIME, I will really implement the code to show maps.

_________________
"Life finds a way." - Ian Malcolm
My WebBlog: PixelDeveloper
English is not my native language, so excuse me for any writing mistakes.


Top
 Profile  
 
PostPosted: Mon Jun 11, 2012 10:48 pm 
Harmlessness does no harm
User avatar

Joined: Tue Sep 14, 2004 8:37 pm
Posts: 3810
Location: Ferriday, LA, US
FelipeFS wrote:
Pheeeeeeeeeeeww... All night working, and the code was fully adapted to XML.

Just out of curiosity Felipe, did you consider JSON for data? I tend to prefer it over XML (which is a bit unwieldy, in my personal view).

Either way is good, was just wondering if you'd looked into it. :)

_________________
What most people don't understand about "enlightenment" is that it is not an end-goal; but where you find yourself just before taking a new "first step."


Top
 Profile  
 
PostPosted: Tue Jun 12, 2012 2:01 am 
Source Code Swashbuckler
User avatar

Joined: Wed Nov 09, 2011 3:58 am
Posts: 199
Location: Brazil
NEVER heard about it! I will take a look how it is. Thank you!

_________________
"Life finds a way." - Ian Malcolm
My WebBlog: PixelDeveloper
English is not my native language, so excuse me for any writing mistakes.


Top
 Profile  
 
PostPosted: Tue Jun 12, 2012 11:23 am 
Source Code Swashbuckler
User avatar

Joined: Wed Nov 09, 2011 3:58 am
Posts: 199
Location: Brazil
Swim, little fish, swin for your life!
http://www.youtube.com/watch?v=tcJlSJyhNa8&feature=plcp

Physics Engine - what is working:
    [li]Force application;[/li]
    [li]Velocity;[/li]
    [li]Acceleration;[/li]
    [li]Friction(specified for an object, and uncconditional, which works every moment);[/li]

_________________
"Life finds a way." - Ian Malcolm
My WebBlog: PixelDeveloper
English is not my native language, so excuse me for any writing mistakes.


Top
 Profile  
 
PostPosted: Tue Jun 12, 2012 2:02 pm 
Funky Monkey

Joined: Thu Sep 09, 2004 1:17 pm
Posts: 1553
Location: burrowed
needs a bigger fish thats hunting him :D

looks good though

_________________
Long pork is people!

wzl's burrow


Top
 Profile  
 
PostPosted: Fri Jun 15, 2012 5:36 am 
Gamer Geek
User avatar

Joined: Sat Feb 25, 2012 7:07 pm
Posts: 29
Location: California
weezl wrote:
needs a bigger fish thats hunting him :D


There is always a bigger fish ...

_________________
It's not truly yours, until you void the warranty.
Most of my problems: "I can fix that! ... oops".


Top
 Profile  
 
PostPosted: Fri Jun 15, 2012 6:17 am 
Source Code Swashbuckler
User avatar

Joined: Wed Nov 09, 2011 3:58 am
Posts: 199
Location: Brazil
tarpeyd12 wrote:
weezl wrote:
needs a bigger fish thats hunting him :D


There is always a bigger fish ...


Yeah! ahahahahahah that's way I did it! :rofl

Here is a link for download: [Link]

The files need to be extracted in "C:\", I forgot to implement to make the game search the data and resource files in another directory.

And the game is a bit slow, because the Shark(the enemy) make a math to get the angle between itself and the fish every time. Such math sould be done at a time interval, but the TimerEvent is being implemented yet.

_________________
"Life finds a way." - Ian Malcolm
My WebBlog: PixelDeveloper
English is not my native language, so excuse me for any writing mistakes.


Top
 Profile  
 
PostPosted: Fri Jun 15, 2012 6:20 am 
Source Code Swashbuckler
User avatar

Joined: Wed Nov 09, 2011 3:58 am
Posts: 199
Location: Brazil
OH, yeah, and don't be scared with the console window with a lot of messages. It is for debugging.

_________________
"Life finds a way." - Ian Malcolm
My WebBlog: PixelDeveloper
English is not my native language, so excuse me for any writing mistakes.


Top
 Profile  
 
PostPosted: Fri Jun 15, 2012 6:37 am 
Gamer Geek
User avatar

Joined: Sat Feb 25, 2012 7:07 pm
Posts: 29
Location: California
FelipeFS wrote:
OH, yeah, and don't be scared with the console window with a lot of messages. It is for debugging.


you mean this console output?

Image

_________________
It's not truly yours, until you void the warranty.
Most of my problems: "I can fix that! ... oops".


Top
 Profile  
 
PostPosted: Fri Jun 15, 2012 6:41 am 
Source Code Swashbuckler
User avatar

Joined: Wed Nov 09, 2011 3:58 am
Posts: 199
Location: Brazil
Yeah =)

And... how are you running it on Ubuntu???

_________________
"Life finds a way." - Ian Malcolm
My WebBlog: PixelDeveloper
English is not my native language, so excuse me for any writing mistakes.


Top
 Profile  
 
PostPosted: Fri Jun 15, 2012 6:43 am 
Gamer Geek
User avatar

Joined: Sat Feb 25, 2012 7:07 pm
Posts: 29
Location: California
FelipeFS wrote:
And... how are you running it on Ubuntu???


Wine, it is a system to run windows programs on non-windows machines.

_________________
It's not truly yours, until you void the warranty.
Most of my problems: "I can fix that! ... oops".


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 76 posts ]  Go to page Previous  1, 2, 3, 4  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group