real-time graphics 
Author Message
 real-time graphics

        For my first RealBasic program I decided to have a black pixel
run around eating green pixels.  I can only see the grazing damage when
I stop the whole thing with, say, a mouse-down event.  I did this:
- gave Window1 a Picture property, p
- in Open, did newPicture and made the green field
- in Paint, g.DrawPicture self.p,0,0
- in Action of Button1 I call a new method "eat"
- eat does the moving and changing green pixels to white by using
self.p.pixel,
calling Canvas1.graphics.drawPicture self.p,Canvas1.left,Canvas1.top
and (blush) checking system.mouseDown so I can stop the dang thing.

        What do I need to do to see the little black pixel running
around destroying green?
        Thanks for any hints.  Oh, and I realize that I could do a
better job at organizing things in OOP fashion.  That's next!

Alistair
--

  Phone: 604-822-2645            | 6270 University Boulevard
  Fax:   604-822-2416            | Vancouver, Canada, V6T 1Z4



Fri, 17 Sep 2004 15:25:08 GMT  
 real-time graphics

Quote:

>         For my first RealBasic program I decided to have a black pixel
> run around eating green pixels.

Sounds like fun.

Quote:
> I can only see the grazing damage when I stop the whole thing with, say,
> a mouse-down event.

Sounds like you're using a tight loop in OS X.  Better to do your
animation from a Timer, which will both let you regulate the speed, and
avoid the problem you're seeing which is caused by the fact that all
windows on OS X are double-buffered.

You might enjoy some of my graphics/game demos here:
     http://www.strout.net/info/coding/rb/

Cheers,
- Joe

--
,------------------------------------------------------------------.
|    Joseph J. Strout         Check out the Mac Web Directory:     |

`------------------------------------------------------------------'



Sat, 18 Sep 2004 02:15:20 GMT  
 real-time graphics

Quote:
> Sounds like you're using a tight loop in OS X.  Better to do your
> animation from a Timer, which will both let you regulate the speed, and
> avoid the problem you're seeing which is caused by the fact that all
> windows on OS X are double-buffered.

A tight loop or a slack loop doesn't makes any difference. The problem
is that a canvas is not refreshed from inside a Procedure or function.
Well you can force a refresh, but you will get whatever you have in the
Paint event of the Canvas.  So if you don't have any code in there then
you will get a blank screen or if you have some code in there then it
will always be the same thing.

But joe is right in saying that it has to be done from a Timer.  Or you
can use sprite

Jacques



Sat, 18 Sep 2004 04:16:24 GMT  
 real-time graphics

Quote:

> > Sounds like you're using a tight loop in OS X.  Better to do your
> > animation from a Timer, which will both let you regulate the speed, and
> > avoid the problem you're seeing which is caused by the fact that all
> > windows on OS X are double-buffered.

> A tight loop or a slack loop doesn't makes any difference. The problem
> is that a canvas is not refreshed from inside a Procedure or function.

:)  I'm not sure what you mean by "a slack loop".  A tight loop is one
that takes place entirely within a procedure or function, and not in a
thread.  This is as opposed to one based on a timer, or in a thread.

Quote:
> But joe is right in saying that it has to be done from a Timer.  Or you
> can use sprite

Or you can force OS X to flush the buffer with a Declare, or you could
use an Rb3DSpace -- there are many ways to skin the cat.  But using a
Timer is probably easiest.

Best,
- Joe

--
,------------------------------------------------------------------.
|    Joseph J. Strout         Check out the Mac Web Directory:     |

`------------------------------------------------------------------'



Sat, 18 Sep 2004 06:08:03 GMT  
 real-time graphics

Quote:

> What do I need to do to see the little black pixel running around
> destroying green? Thanks for any hints. Oh, and I realize that I could
> do a better job at organizing things in OOP fashion. That's next!

You might be better off not doing it very OOP if speed is a problem.
OOP and speed pull in different directions sometimes.

--
Email Cleaner does convenient re-wrapping on badly wrapped emails and
newsgroup-posts. Badly wrapped lines is a problem every Internet User
comes across, Email Cleaner solves it! It also has many other features.

Email Cleaner works from inside all of your Mac programs, from one
button click.

<www.elfdata.com/emailcleaner/>



Sun, 19 Sep 2004 01:41:01 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. (Fwd) Real time Graphics in Clarion For Windows

2. Real-time Graphics

3. serial port/real time graphics display

4. Real-time Graphics

5. Time to REAL & REAL to time

6. Announce: Real-time 3D Graphics for Tcl/Tk

7. "Real Time" Graphics

8. real time dispaly of time.

9. Help!: problem with fast timing for real-time application on PC

10. Help!: problem with fast timing for real-time application on PC

11. DOS compressed date/time into real date/time

12. real time, time series display

 

 
Powered by phpBB® Forum Software