TGC Codebase Backup



MiniTron by Richard Davey

29th Aug 2003 23:35
Summary

I wanted to write a game in 20 lines of code or less. Thus MiniTron was born. Proper 2 player action, includes very basic A.I for the enemy, keyboard handling and math based collis



Description

==========================================================
A Screaming Product Of The DARKFORGE (www.darkforge.co.uk)
==========================================================

Title

MiniTron

Version

1.0

Date

28th May 2000

Files

minitron.dba 1716 Bytes
minitron.gif 3097 Bytes

Programmer

Richard Davey
rich@fatal-design.com

DB Version

DarkBasic v1.05 (Registered)

License

Public Domain

Comments

I wanted to write a game in 20 lines of code or less. Thus
MiniTron was born. Proper 2 player action, includes very
basic A.I for the enemy, keyboard handling and math based
collision!

==========================================================
(c) www.darkforge.co.uk 2000
==========================================================



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    ` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
`               MiniTron
` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
` By Rich Davey (rich@fatal-design.com)
` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
` Music listened  to while  coding this
` Interstellar Harmony Volume 1
` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
` Note:
`
` The objective was to write a complete
` game in 20 lines of code or less. I
` did it in 19. Includes 2 players and
` rudimentary Artificial Intelligence!

sync rate 0 : sync on : hide mouse : dim grid(639,479) : ink rgb(255,255,255),0

for a=0 to 639 : grid(a,0)=1 : grid(a,479)=1 : dot a,0 : dot a,479 : next a
for a=0 to 479 : grid(0,a)=1 : grid(639,a)=1 : dot 0,a : dot 639,a : next a

x=50 : y=100 : d=2 : keycheck=timer() : ex=600 : ey=100 : ed=4 : c=0

do

	if d=1 : dec y : endif : if d=2 : inc x : endif : if d=3 : inc y : endif : if d=4 : dec x : endif
	if ed=1 : dec ey : endif : if ed=2 : inc ex : endif : if ed=3 : inc ey : endif : if ed=4 : dec ex : endif

	if grid(x,y)=1 then set cursor 0,0 : print "YOU DIE" : wait key : end
	if grid(ex,ey)=1 then set cursor 0,0 : print "YOU WIN" : wait key : end

	ink rgb(255,0,0),0 : dot x,y : ink rgb(0,255,0),0 : dot ex,ey : grid(x,y)=1 : grid(ex,ey)=1

	if timer()>keycheck+125 : if leftkey()=1 : dec d : keycheck=timer() : if d=0 : d=4 : endif: endif : if rightkey()=1 : inc d : keycheck=timer() : if d=5 then d=1 : endif : endif

	if ed=1 : if grid(ex,ey-1)=1 then c=1 : endif
	if ed=2 : if grid(ex+1,ey)=1 then c=1 : endif
	if ed=3 : if grid(ex,ey+1)=1 then c=1 : endif
	if ed=4 : if grid(ex-1,ey)=1 then c=1 : endif

	if c=1 : inc ed : c=0 : if ed=5 then ed=1
	if ed=0 then ed=4 : endif

	sync

loop