Posts: 3,616
Threads: 287
Joined: Jan 2003
So here's what I figure three cats high on catnip might look like if they were in a race...fine, I was trying to make a horse-racing game but I got bored and stopped half-way through. So shoot me. It was the morning of January 1st, not the best time to do anything that involves thinking.
Code: clr=15
screenres 640,480,8
paint (100,100),7
for x=0 to 64
line(x*10,10)-(x*10+10,15),clr,bf
if x/2=x\2 then
clr=0
else
clr=15
end if
next
line (0,471)-(640,471),15
type horse
x as integer
y as integer
speed as integer
clr as integer
end type
dim horses(1 to 3) as horse
horses(1).x=100
horses(1).y=470
horses(2).x=315
horses(2).y=470
horses(3).x=540
horses(3).y=470
horses(1).clr=4
horses(2).clr=2
horses(3).clr=1
horses(1).speed=1
horses(2).speed=1
horses(3).speed=1
for i=1 to 3
line (horses(i).x,horses(i).y)-(horses(i).x+5,horses(i).y-10),horses(i).clr,bf
next
randomize timer
do
k$=inkey
if k$=chr(27) then end
for i=1 to 3
if cint(rnd)=1 then
horses(i).speed+=rnd/1.5
else
horses(i).speed-=rnd/1.5
end if
line (horses(i).x,horses(i).y)-(horses(i).x+5,horses(i).y-10),7,bf
horses(i).y-=horses(i).speed
line (horses(i).x,horses(i).y)-(horses(i).x+5,horses(i).y-10),horses(i).clr,bf
if horses(i).y<=10 then exit do
next
sleep 50
loop
sleep
Yeah, I still code. Not very well.
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Posts: 961
Threads: 81
Joined: Apr 2005
Haha! Looks like me after leaving a pub... trying to get back in.
Screwing with your reality since 1998.
Posts: 324
Threads: 12
Joined: Nov 2005
Awesome program, short and sweet . Here's a version that will work with the latest CVS compiler, for anyone interested.
Code: type horse
as integer x, y, speed, clr
end type
dim horses(1 to 3) as horse = _
{ /' x, y, speed, color '/ _
(100, 470, 1, 4), _
(315, 470, 1, 2), _
(540, 470, 1, 1) _
}
'' setup screen, draw start and finish lines
''
screenres 640, 480, 8
paint (100, 100), 7
randomize timer
for x as integer = 0 to 64
line(x * 10, 10)-(x * 10 + 10, 15), iif (0 = x mod 2, 0, 15), bf
next
line (0, 471)-(640, 471), 15
'' race the horses
''
do
dim key as string = inkey
if (chr(27) = key) then exit do
for i as integer = 1 to 3
'' erase
''
line (horses(i).x, horses(i).y)-(horses(i).x + 5, horses(i).y - 10), 7, bf
'' update position and redraw
''
horses(i).speed += iif(cint(rnd) = 1, rnd / 1.5, -rnd / 1.5)
horses(i).y -= horses(i).speed
line (horses(i).x, horses(i).y)-(horses(i).x + 5, horses(i).y - 10), horses(i).clr, bf
'' are we there yet ? :)
''
if (horses(i).y <= 10) then exit do
next
sleep 50
loop
sleep
stylin:
Posts: 3,616
Threads: 287
Joined: Jan 2003
I'm way out of the loop. What is this new CVS compiler? What's CVS, for that matter? (It sound familiar...)
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Posts: 421
Threads: 22
Joined: Oct 2005
It's a constantly updated version of FreeBASIC, I think. I forget where I found it.
In the beginning, there is darkness â the emptiness of a matrix waiting for the light. Then a single photon flares into existence. Then another. Soon, thousands more. Optronic pathways connect, subroutines emerge from the chaos, and a holographic consciousness is born." -The Doctor
Posts: 324
Threads: 12
Joined: Nov 2005
CVS [ http://en.wikipedia.org/wiki/Concurrent_Versions_System ] helps people coordinate development of a project. FreeBASIC - the compiler and all runtime libraries that go along with it - is open sourced, so anyone can download it and build it themselves and have the latest (and greatest) version to play with. CVS builds typically can have bugs or are otherwise less polished than official releases, but they let you see what direction the language is moving in (notably, toward supporting object orientated programming constructs).
To build the FreeBASIC sources on your own you need the right environment set up. Linux users are pretty much set to go, a few dev libraries is all that is usually needed. Windows users have a little bit harder time, but the wiki provides the information you need:
http://www.freebasic.net/wiki/wikka.php?...CVSCompile
Some people have set up sites to download daily or weekly compiler packages that are either pre-built or use scripts to build automagically These are listed below in no particular order:
For Windows: http://www.freebasic.net/forum/viewtopic.php?t=6439
For Linux: http://www.freebasic.net/forum/viewtopic.php?t=6438
For DOS: http://www.freebasic.net/forum/viewtopic.php?t=6437
Cheers, and happy hacking !
stylin:
Posts: 3,616
Threads: 287
Joined: Jan 2003
Ah, who needs OOP, anyway. I like FB as it is. Besides, my level of programming isn't exactly sensitive to small changes in compilers.
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Posts: 324
Threads: 12
Joined: Nov 2005
Well, as the compiler progresses, bugs will be fixed, and other things may/will change from the last official release (version .17b already has loads of changes/additions from .16b). If you don't keep up with these changes, the code you write may not work properly in future official releases (FreeBASIC is still in beta, after all). For example, a few changes in .17b break code written for .16b; if you have alot of it, it's that much more code you have to rewrite/maintain (one of the reasons why the new -lang compiler switch was created). So in the end, it's a benefit to try and write code that will work with future versions.
OOP isn't about new FreeBASIC language constructs, it's just a method of programming. The new features being added to FreeBASIC can help with OOP, but in no way does using them mean that you are writing object-orientated code. Conversely, object-orientated code can be written without using these features, like in QuickBASIC or C.
OOP is not a silver bullet by any means, but there are some situations that greatly benefit from it, and by definition OO code is inherently more robust and easier to extend/modify than non-OO code (so just by following it do you gain more options in the code you design, because the principles of OOP force those options to be there). For more imformation, read this thread: http://www.gamedev.net/community/forums/...ID=2666170.
stylin:
|