1. Not to be impatient.....

------=_NextPart_000_004D_01C066AD.C1A89480
        boundary="----=_NextPart_001_004E_01C066AD.C1A89480"


------=_NextPart_001_004E_01C066AD.C1A89480
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hello,=20

    I don't want to come across as impatient, but I sent an e-mail a =
while ago regarding my Snake program. I've got the message here. Please =
respond, I'm waiting in programming limbo:

 I've included my program and the problem is the pause when you go left, =
then hit right. the snake stops. I know the  problem.....the solution =
evades me.............but I think it has something to do with the number =
left in "desc". Can anyone help? Thanks


-Thomas

------=_NextPart_001_004E_01C066AD.C1A89480
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hello, </FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; I don't want to come =
across as=20
impatient, but I sent an e-mail a while ago regarding my Snake program. =
I've got=20
the message here. Please respond, I'm waiting in programming =
limbo:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>
<DIV><EM><FONT face=3DArial size=3D2>&nbsp;I've included my program and =
the problem=20
is the pause when you go left, then hit right. the snake stops. I know =
the&nbsp;=20
problem.....the solution evades me.............but I think it has =
something to=20
do with the number left in "desc". Can anyone help? =
Thanks</FONT></EM></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>

------=_NextPart_001_004E_01C066AD.C1A89480--

------=_NextPart_000_004D_01C066AD.C1A89480
        name="snake.bmp"

new topic     » topic index » view message » categorize

2. Re: Not to be impatient.....

On Fri, 15 Dec 2000 15:43:23 -0800, Thomas wrote:

>Hello,
>
>    I don't want to come across as impatient, but I sent an e-mail a while
>ago regarding my Snake program. I've got the message here. Please respond,
>I'm waiting in programming limbo:
>
> I've included my program and the problem is the pause when you go left,
>then hit right. the snake stops. I know the  problem.....the solution
>evades me.............but I think it has something to do with the number
>left in "desc". Can anyone help? Thanks
>
>
>-Thomas

Three quick comments before I even look closer at this:

1.)  This is not the same program you sent the first time.
2.)  What good is 'use_vesa(1)' doing when you've got it after
your 'graphics_mode' call?  (check the reference manual; do you even need
it?)
3.)  Are you trying to give us seizures with the 'bk_color(n)' call in your
main loop?

I'll see what I can do to help when I get home (unless somebody else beats
me to it).

-- Brian

new topic     » goto parent     » topic index » view message » categorize

3. Re: Not to be impatient.....

On Fri, 15 Dec 2000 15:43:23 -0800, Thomas wrote:

>Hello,
>
>    I don't want to come across as impatient, but I sent an e-mail a while
>ago regarding my Snake program. I've got the message here. Please respond,
>I'm waiting in programming limbo:

OK Thomas, here is but one possible solution.  Somehow I experienced 'de ja
vue' while working on this (only the first time it seemed like I was
working with some kind of aircraft...).

I'll leave it to you to clean up the trails and make it look like a real
snake.

I hope this helps.
(and I hope I haven't done too much for you; I know you don't like having
people actually doing things for you but as you already know, I feel I can
teach best by example...)
  --------------------

include graphics.e
include get.e
include image.e

constant
  -- adjustable parameters
  DELAY = .05,
  STEP  = 5,

  -- resolution for graphics_mode(259)
  MAX_X = 800,
  MAX_Y = 600,

  -- index parameters
  X = 1,
  Y = 2,

  -- define special keys
  ESC   = 27,
  S_DIR = {
    328,  -- UP
    331,  -- LEFT
    333,  -- RIGHT
    336 },-- DOWN
  DXDY = { {0,-STEP}, {-STEP,0}, {STEP,0}, {0,STEP} }

  --------------------

-- try setting 800x600x256 graphics mode
if graphics_mode(259) then
  -- try forcing VESA graphics mode
  --  (I'm not sure if this is useful since the first try
  --   might succeed but it just doesn't look right...??)
  use_vesa(1)
  if graphics_mode(259) then
    -- if still no go, then give up
    puts( 1, "Unable to set graphics mode... aborting." )
    abort(1)
  end if
end if

object snake
integer keypressed, s_dir
sequence s_pos, dxdy, s_size

s_pos = {100,100}
dxdy  = {STEP,0}

snake = read_bitmap( "snake.bmp" )
if atom( snake ) then
  printf( 1, "Error #%d opening 'snake.bmp'.", snake )
  if wait_key() then
    abort( 2 )
  end if
else
  s_size = { length( snake[2][1] ), length( snake[2] ) }
end if

all_palette( snake[1]/4 )
bk_color( BLUE )

  --------------------

procedure delay( atom i )
  i += time()
  while time() < i do
    -- nothing
  end while
end procedure

  --------------------

procedure end_game()
  -- restore graphics mode
  if not graphics_mode(-1) then
    puts( 1, "The end.  Next key press exits..." )
    -- wait for next key
    if wait_key() then
      abort(0)
    end if
  end if
end procedure

  --------------------

procedure bound_chk()
  if s_pos[X] < 0 or s_pos[Y] < 0
  or s_pos[X] > MAX_X - s_size[X]
  or s_pos[Y] > MAX_Y - s_size[Y] then
    position(2,1)
    puts( 1, "You crashed.  Press a key..." )
    if wait_key() then
      end_game()
    end if
  end if
end procedure

  --------------------
  -- main program loop
  --------------------
while 1 do
  keypressed = get_key()

  -- this if-block is just some debugging code
  if keypressed > 0 then
    position( 1, 1 )
    printf( 1, "key pressed: %d  ", keypressed )
  end if

  -- is input an arrow key?
  s_dir = find( keypressed, S_DIR )
  -- if so, change direction
  if s_dir then
    dxdy = DXDY[s_dir]
  -- if ESC pressed, then exit loop
  elsif keypressed = ESC then
    exit
  end if
  -- move snake
  s_pos += dxdy
  -- make sure we don't go off the screen
  bound_chk()
  display_image( s_pos, snake[2] )
  delay( DELAY )
end while

end_game()

new topic     » goto parent     » topic index » view message » categorize

4. Re: Not to be impatient.....

No Brian, I think you wrote the whole thing. hahaha

euman at bellsouth.net

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu