Re: Image Not Appearing
- Posted by ChrisB (moderator) Dec 22, 2011
- 1794 views
useless_ said...
jimcbrown said...
To get you started, here's a really basic state machine that does what you want.It just bounces a ball (well asterisk) down to a corner of the screen and then back up.
I stripped this down to the absolute minimalist code, so others can help you fine tune it without requiring SDL.
integer x integer y integer x_way integer y_way x = 1 y = 1 x_way = 1 y_way = 1 while 1 do clear_screen() position(x, y) puts(1, "*") x += x_way y += y_way if x >= 10 then x_way = -1 elsif x < 2 then x_way = 1 end if if y >= 10 then y_way = -1 elsif y < 2 then y_way = 1 end if machine_proc(64, 1) end while
In the interest of code that works and is easier to read, i thought i'd waste everyone's time with the following modifications:
include std/os.e -- for sleep() integer x integer y integer x_way integer y_way x = 1 y = 1 x_way = 1 y_way = 1 while 1 do clear_screen() position(x, y) puts(1, "*") x += x_way y += y_way if x >= 25 then x_way = -1 elsif x < 2 then x_way = 1 end if if y >= 60 then y_way = -1 elsif y < 2 then y_way = 1 end if sleep(0.05) end while
If someone else would add paddles in the next week or so, we'd have a dosbox monochrome two-player game in time for the 40th anniversary of Pong(tm).
useless
Oh, well, why didn't you say (not sdl, allegro, an alternative)
http://euallegro.wikispaces.com/Games
Chris