Re: Bad Co-ordinates
On Tue, 26 Sep 2000 16:34:52 -0700, Thomas wrote:
>Well, I've written a program with a lot of help from Brian and it's
>still.....broken. My fault really. Anyways, I've attatched it and the
>problems are..
>
>1. If you move left to the limits, it crashes
Then don't let it move left to the limits...
>2. If you go too far right, well, it goes to far (past screen limits) and
>you can't go left. I know what the problem is, but the solution evades
>me.
Check your logic... you rather mangled the structure of the code I gave
you and that makes it more difficult to find errors in logic.
>3. There seems to be a green border in 256 mode......
That is a result of using 'all_palette'. I don't remember which palette
index corresponds to the border color, but you are changing it from black
to green when you use 'all_pallete'.
>PS. How d'you like my jet?
Nice jet...
Try this:
---------
include image.e
include keyread.e
include graphics.e
---lalala
constant
-- Scan Codes:
ESC = 1,
UP = 328,
DOWN = 336,
LEFT = 333,
RIGHT = 331,
-- Indexes to enhance readability of code:
X = 1,
Y = 2,
MoveStep = 5, -- number of pixels to move jet on key press
BmpSize = {63,76}, -- size of bitmap
MAX = {640,400} -- size of screen in mode 256
integer gmode
sequence jetmove,desc
integer ix,iy
ix=200
iy=300
use_vesa(1)
gmode=graphics_mode(256)
jetmove=read_bitmap("jetmove.BMP")
all_palette(jetmove[1]/4)
text_color(10)
puts(1,"arrows move, ESC quits")
procedure wait( atom n )
n += time()
while time() < n do
-- nothing
end while
end procedure
while 1 do
desc = get_keys()
position(2,1)
? desc
display_image({ix,iy},jetmove[2]) -- show jet
if length( desc ) > 0 then -- a key is being pressed
if desc[1] = ESC then
abort(0)
elsif desc[1]=LEFT then
if ix < MAX[X]-BmpSize[X] then
ix += MoveStep
end if
elsif desc[1]=RIGHT then
if ix > 0 then
ix -= MoveStep
end if
elsif desc[1]=UP then
if iy > 0 then
iy -= MoveStep
end if
elsif desc[1]=DOWN then
if iy < MAX[Y]-BmpSize[Y] then
iy += MoveStep
end if
end if
wait(0.0005)
end if
end while
-- Brian
|
Not Categorized, Please Help
|
|