### 1. Graphics Problem

```My problem is this:  I have a 2-D shape, moving over a complex
background, and am having trouble cleaning up after the shape has moved.
I have thought of using get_pixel but am sure that this would slow down
the the speed of the 2-D shape moving.

I also have another question that is slightly related to the last
one.  I have coded the shape to move a certain number of pixels each
turn in a loop.  But the speed is dictated by how fast the computer can
run the instructions, is there any other way to determine (to set), the
speed at which the a shape moves, because at the moment the speed the
shape is moving at is machine depandant.
Now for the question, is there anyway to code it so that the shape moves
at a set speed, and is does not change speed, (to much), on different
range of systems.

I would be very Grateful if you can help me with any of these problems.

Roger.
```

### 2. Re: Graphics Problem

```On Mon, 10 Mar 1997 13:23:35 +0000 ROGER <rwd2 at COVENTRY.AC.UK> writes:
>---------------------- Information from the mail header
> I have coded the shape to move a certain number of pixels each
>turn in a loop.  But the speed is dictated by how fast the computer
>can run the instructions, is there any other way to determine (to set),
>the speed at which the a shape moves, because at the moment the speed
the
>shape is moving at is machine depandant.
>Now for the question, is there anyway to code it so that the shape
>moves at a set speed, and is does not change speed, (to much), on
different
>range of systems.

>               Roger

You have to create a loop to go Either a specific distance and
time how long it took OR.
You have to create a loop that goes for a specific amount of time
and count how far it got.

PRO's & CON's

In the first case the distance might not be large enough on really fast
machines to effectively time the distance.
Also the distance might seem to take an eternity on really slow machines.

With the second case you have to put the counter inside the timed loop.
This counter slows down the loop. This means that when you go to
using this loop without the counter inside that it may run faster than
you
anticipated.

Either case.  After you have timed them.  The equation should be
something
like:  count / seconds = count per second OR seconds / count = seconds
per count.
Simple enough?

After you have the counts per second you would pass these values to a
procedure

These functions use the secon method.

function cnts_per_sec()
atom t, cnt
--running this function should take less than a second.
--It should also be relatively accurate.
t = time()
while t = time() do
end while-- I used this loop to initialize the timer.  NOTE: I don't
trust timers much.

t = time()
while t = time() do
cnt = cnt + 1
end while
return cnt / time
end function

procedure my_delay(atom dly)
for A = 1 to dly
dly = A-- This is used for slowing the loop down.
end for
end procedure

atom  one_sec

one_sec = cnts_per_sec()
my_delay(one_sec)
puts(1, "one second\n")
my_delay(5 * one_sec)
puts(1, "five seconds\n")

You can create variations that may be even more accurate.
```

### 3. Re: Graphics Problem

```On Mon, 10 Mar 1997, ROGER wrote:

>     My problem is this:  I have a 2-D shape, moving over a complex
> background, and am having trouble cleaning up after the shape has moved.
> I have thought of using get_pixel but am sure that this would slow down
> the the speed of the 2-D shape moving.

I make the sprite size bigger than the actual object, and "draw" to a
virtual screen to mask it with the background before drawing it to the
real screen.  If you have a 3 pixel black border around the object, you
can move it 6 pixels in any direction without trails.

In the OidZone Programmer's Reference guide I explain the theory in gross
detail and go line by line through my spirte engine code.  Everyone who
wants to do heavy duty graphics work needs my book and source code.

>         I also have another question that is slightly related to the last
> one.  I have coded the shape to move a certain number of pixels each
> turn in a loop.  But the speed is dictated by how fast the computer can
> run the instructions, is there any other way to determine (to set), the
> speed at which the a shape moves, because at the moment the speed the
> shape is moving at is machine depandant.
> Now for the question, is there anyway to code it so that the shape moves
> at a set speed, and is does not change speed, (to much), on different
> range of systems.
>
To set the rate, use the time() function.  Before you draw anything, do a
frameclock=time(), then do your drawing fuctions and screen update stuff,
then do this:

while frameclock2-frameclock<.05  --.05 seconds
frameclock2=time()
end while

It will sit and wait for the time to go by before moving on.  This makes
your code go the same speed on all machines.  You probably want to set the
tick_rate() to 100 frames per second to make time() more accurate, it's
default is 18-20 frames per second.

Michael Packard
Lord Generic Productions
lgp at exo.com http://exo.com/~lgp
A Crash Course in Game Design and Production
http://exo.com/~lgp/euphoria
```

### 4. Re: Graphics Problem

```re: moving at a constant speed.

Once you establish the speed that you want the graphical object to move
across the screen, do something like the following:

loop forever
-- get draw time
x = current ticks

-- draw the object
draw the object

-- calculate the next draw time
x = x + ticks until redraw

-- wait until next draw time
loop while current ticks < x
end loop
end loop

By getting the tick rate before you draw the object, you do not add the time
that it took to draw to the redraw time. If the machine is really slow (like
mine), the wait time will have expires by the time it gets to the wait loop,
and it will never pause.

According to the documentation, can get set tick_rate() to fairly high
granularity (more than the standard 18.2 ticks per second), so you should be
able to time the redraw with good accuracy.

-- David Cuny
```

### 5. Graphics Problem

```I have been playing around with the mouse.ex demo.  When I change to
graphics mode 257 (640x480 256 color) the mouse pointer no longer
appears and the mouse is centered at pixel 1024x1024 and can go up to
2047 in either x or y value.  In essence the upper left 640x480 of my
2047x2047 page is displayed.

So my question is:  Is it my graphics card or is this normal?

Thanks

Bryce Byrd
```

### 6. Re: Graphics Problem

```Bryce Byrd writes:
> I have been playing around with the mouse.ex demo.  When I change to
> graphics mode 257 (640x480 256 color) the mouse pointer no longer
> appears and the mouse is centered at pixel 1024x1024 and can go up to
> 2047 in either x or y value.  In essence the upper left 640x480 of my
> 2047x2047 page is displayed.
>
> So my question is:  Is it my graphics card or is this normal?

There may be two problems here.

1. Graphics modes on DOS beyond VGA (640x480, 16 colors)
were never well standardized. Each graphics chip maker
include machine.e
use_vesa(1)
at the top of your program may help with this.

2. DOS never really supported the use of the mouse above
VGA. However some Euphoria people have worked out
ways of handling the mouse in SVGA. Search the archives
for: mouse svga
Jiri Babor has some good routines. The use of the mouse
in SVGA is not supported directly by ex.exe, only through
routines written by Jiri and also a few other people.

Regards,
Rob Craig
Rapid Deployment Software
http://www.RapidEuphoria.com
```