realbasic-games
[Top] [All Lists]

Re: I need more power captain.

To: realbasic-games at lists dot realsoftware dot com
Subject: Re: I need more power captain.
From: Sam Rowlands <sam at scriptsoftware dot com>
Date: Wed, 28 Sep 2005 19:49:34 +0100
Delivered-to: realbasic-games at lists dot realsoftware dot com
References: <20050928170029 dot 724B8DCFEF3 at lists dot realsoftware dot com>
Asher,
Thanks for replying to my e-mail, this is my first game that I am writing in RB so undoubtedly I am going to be doing things wrong.

On Sep 28, 2005, at 6:00 PM, realbasic-games- request at lists dot realsoftware dot com wrote:

How do I give my application more CPU time?

Use a thread or a loop with #Pragma DisableBackgroundTasks. The latter
is not recommended ;-)

Oh... I forgot about Pragmas...

I have found that when my application/game is running the most CPU I
can obtain is 51% and this gives me a frame rate of 24 when its full
screen (1280*864 on a PBG4 1.5Ghz). Window Manager steals 15% but I
think this because I am trying to redraw the contents a lot.

"redraw the contents" - you mean calling refresh?

Basically, I draw to the window background and then call Window.UpdateNow I found if I didn't then no matter what the frame rate the animation was choppy.

The loop is faster but not good for a windowed app (the OS considers it frozen, you can't move the window or use the menu bar, etc.). Should be
fine fullscreen though.

I am comfortable with those side effects, while the user will be able to run the game in a window it has been designed to run full screen. Although thinking about it, it may be wise to use a thread if the user is playing the game in a window.

I am sure that there is a lot I code to speed up my code here and
there, but it does look a wee bit disappointing at the moment that I
can only get 24 frames on a 1.5 Ghz.

Definitely! How much drawing are you doing, and how are you doing it?
You mentioned drawing to the window background, so I presume you are
using the graphics class?

The game is an Adventure game, like the old Zelda or Pokeyamom (I mean Pokemon). The graphics are all tile based and are dependent on screen size. For arguments sake lets say we are running in 1280 x 854, so each tile is 128 x 128 thats ten tiles wide and 7 high. Its always 10 tiles wide so if its 640 x 480 the tile size is 64. The graphics are scaled when they are loaded to the correct size so no scaling takes place on redraw however each tile is redrawn for each frame. I have designed it like this to account for animation. Each tile is responsible for any animation. Back to 1280 x 854, for each frame redraw it will draw at least 70 128x128 images, I say at least because that is just the background there might or might not be foreground tiles and then there is the main character. So at the most it will be redrawing 140 128x128 images directly into the Window's graphics (on the Mac, on Windows it will draw to an image and that image will then be draw to the window background to prevent flicker). As I said earlier after each frame has been drawn I call window.UpdateNow otherwise you just see a blank window covering your screen!

I have glanced at the sprite surface but I figured I could it in the graphics class as I am comfortable using the graphics (most of my other applications use graphics classes).

As I meantioned earlier this is my first game I have written (I wrote a couple of point and click games when I was a kid). I am used to working in RB, but I can see now how I am dealing with a whole new kettle of fish!

Mahalo & Aloha,

Sam Rowlands

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>