Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / 2d snake game

Author
Message
Crazy Programmer
AGK Developer
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Lost in AGK
Posted: 7th Sep 2004 08:14
hey guys i made a snake game i always liked snake and when i got dark basic pro i desided to program it here it is
[/code]sync rate 0
sync on
hide mouse

` our snake sprite

ink rgb(225,345,345),0
box 1,1,15,15
get image 1,0,0,16,16

` our fruit

ink rgb(250,350,450),0
box 1,1,15,15
get image 2,0,0,16,16

` our border

ink rgb(150,250,350),0
line 1,1,15,15
get image 3,0,0,16,16

` "where is the snake?" array
` because the snake is 16x16 in size the game grid is 40x30

dim grid(40,30)

` add the border to the array

for a=0 to 40
grid(a,0) = 1201
grid(a,29) = 1201
next a

for a=0 to 30
grid(0,a) = 1201
grid(39,a) = 1201
next a

` initial variables

` d = direction (1=up, 2=right,3=down,4=left)
` x and y are starting location for the snake (must be offset of 16)
` eaten is the fruit value (1 = onscreen, 0 = eaten)
` speed is the delay between the snake moving in ms, decrese for speed!

d = 2
x = 320
y = 240
eaten = 1
score = 500
speed = 150
length = 2
placed = 0
t = timer() + speed

set text opaque
ink rgb(255,255,255),0

create bitmap 1,640,480

` the main loop

do

cls 0

if upkey() and d<>3 then d=1
if downkey() and d<>1 then d=3
if leftkey() and d<>2 then d=4
if rightkey() and d<>4 then d=2

` if it's time to redraw the snake then do so here

if timer()>t

if d=1 then dec y,16
if d=2 then inc x,16
if d=3 then inc y,16
if d=4 then dec x,16

if grid(x/16,y/16) > 0 and grid(x/16,y/16) < 1500
goto dead
endif

` have we hit some fruit? If so increase length and score

if grid(x/16,y/16) = 1500
inc length
grid(x/16,y/16) = length
eaten = 1
inc score,25
else
grid(x/16,y/16) = length
endif

t = timer() + speed

` length cascade

for a=0 to 40
for b=0 to 30
if grid(a,b) > 0 and grid(a,b) < 1201
temp = grid(a,b)
dec temp
grid(a,b) = temp
endif
next b
next a

endif

` new fruit (make sure it's not placed on an already occupied location)

if eaten = 1

repeat

fx = 2 + rnd(37)
fy = 2 + rnd(27)

if grid(fx,fy) = 0 then placed = 1

until placed = 1

grid(fx,fy) = 1500
eaten = 0
placed = 0

endif

` draw the game grid - this draws the game screen each sync

for a=0 to 40
for b=0 to 30

tempg = grid(a,b)
if tempg > 0
if tempg = 1500 then paste image 2,a*16,b*16
if tempg = 1201 then paste image 3,a*16,b*16
if tempg < 1201 then paste image 1,a*16,b*16
endif

next b
next a

` un-comment this line to see the debug information instead of the score
` t$ = "X: " + str$(x/16) + " Y: " + str$(y/16) + " FPS: " + str$(screen fps()) + " Length: " + str$(length) + " "
t$ = "SCORE: " + str$(score) + " "
text 0,0,t$

copy bitmap 1,0
sync

loop


dead:

blur bitmap 0,2
set current bitmap 0

repeat

center text 320,240,"haha u lose!"
sync

until spacekey()=1

end[code]

WILL
Richard Davey
Retired Moderator
24
Years of Service
User Offline
Joined: 30th Apr 2002
Location: On the Jupiter Probe
Posted: 7th Sep 2004 08:30
Umm kid, that's MY source code I released into the CodeBase with nothing more than the end message changed and my copyrigh message removed. You might want to be a bit more careful what you claim for your own.

"I am not young enough to know everything."
- Oscar Wilde
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 7th Sep 2004 08:34
LMFAO!!!

I wonder if anyone will enter it into the compo.


Van-B


Muhahahahaha.
Eric T
23
Years of Service
User Offline
Joined: 7th Apr 2003
Location: My location is where I am at this time.
Posted: 7th Sep 2004 08:35
lol, he's posted it in more then one place... on the creator of the codes forums. What an idiot.

AMD 64bit 3200+, Gigabyte GA-K8NS Pro motherboard, 512meg HYPER RAM, ATI Radeon 9600XT 128mb, 120GB Maxtor 7200RPM, http://www.liquidzsnake.dbspot.com/nFinityV.2.txt
Teh Go0rfmeister
22
Years of Service
User Offline
Joined: 17th Aug 2003
Location:
Posted: 7th Sep 2004 08:39 Edited at: 7th Sep 2004 08:51
there is a mightly load of snake stuff in the codebase.

ps- learn how to use


edit- "
"

edit: bah...

Richard Davey
Retired Moderator
24
Years of Service
User Offline
Joined: 30th Apr 2002
Location: On the Jupiter Probe
Posted: 7th Sep 2004 09:28
Quote: "I wonder if anyone will enter it into the compo."


Heh.. I'll be looking out for it!

"I am not young enough to know everything."
- Oscar Wilde
Crazy Programmer
AGK Developer
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Lost in AGK
Posted: 7th Sep 2004 12:42
umm r u sure becuz me and my friend worked on this forabout 2 weeks
but sence u copyed righted it i guess its yours i will stop posting it sorry for the trouble

WILL
Richard Davey
Retired Moderator
24
Years of Service
User Offline
Joined: 30th Apr 2002
Location: On the Jupiter Probe
Posted: 7th Sep 2004 19:22 Edited at: 7th Sep 2004 19:23
Quote: "umm r u sure becuz me and my friend worked on this forabout 2 weeks"


Yes I'm very sure! and you know it. You didn't even change the variable names!

You can see my original snake game in the CodeBase here:

http://www.thegamecreators.com/?m=codebase_view&i=aef4c5d3b16aa49ef2716a87b5a8690f

Please, don't try telling me you worked on that code for 2 weeks, it must have taken all of 2 minutes to change the game over text! I have no problem with you using the code to learn from, add things to and generally enhance - that is why I put it into CodeBase in the first place. But I draw the line when others claim my work is theirs.

Cheers,

Rich

"I am not young enough to know everything."
- Oscar Wilde
David T
Retired Moderator
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 7th Sep 2004 19:27
Quote: "umm r u sure becuz me and my friend worked on this forabout 2 weeks
but sence u copyed righted it i guess its yours i will stop posting it sorry for the trouble"


You little theiving liar.

Get 15 new commands, all the date / time commands left out of DBPro for free!
DOWNLOAD PLUGINS HERE: http://www.davidtattersall.me.uk/ and select "DarkBasic"
Flashing Blade
23
Years of Service
User Offline
Joined: 19th Oct 2002
Location: United Kingdom
Posted: 7th Sep 2004 23:48
Get a book called 4 past midnight by Stephen King and read the story in it called "Secret Garden" (I think thats the name).

After you read it you'll know that if you get a stranger from Missippi Knocking at your door its all in your head.


The word "Gullible" cannot be found in any English Dictionary.
Crazy Programmer
AGK Developer
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Lost in AGK
Posted: 8th Sep 2004 07:25
ok i will use it to learn and right my own snake and when i finish it i will let u know to show u and u can aprove it cya

WILL
Eric T
23
Years of Service
User Offline
Joined: 7th Apr 2003
Location: My location is where I am at this time.
Posted: 8th Sep 2004 08:00
Quote: "Secret Garden"


Or you can watch the movie "Secret Window", which is based off the book. Johnny Depp did a good role in that one.

AMD 64bit 3200+, Gigabyte GA-K8NS Pro motherboard, 512meg HYPER RAM, ATI Radeon 9600XT 128mb, 120GB Maxtor 7200RPM, http://www.liquidzsnake.dbspot.com/nFinityV.2.txt
Axelman
22
Years of Service
User Offline
Joined: 18th Oct 2003
Location: Parallel Universe
Posted: 22nd Sep 2004 13:12
yup, he sure did.

Really enjoyed that movie...

43% of Percentages are made up on the spot.
Game pro
22
Years of Service
User Offline
Joined: 21st Mar 2004
Location: Usa
Posted: 30th Sep 2004 14:58
Here is a tip, dont mess with an administrator or moderator.

I am a newb at DbasicPro creator.
BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 1st Oct 2004 03:11
It's got to be CMC

BatVink
http://biglaugh.co.uk/catalog AMD 3000+ Barton, 512Mb Ram, 120 Gig Drive space, GeForce 5200 FX 128 Mb, Asus A7N8X Mobo.
Terms & Conditions apply

Login to post a reply

Server time is: 2026-06-11 17:32:19
Your offset time is: 2026-06-11 17:32:19