Just a simple program that creates a bunch of crystals and then you guide a character around to collect them. The code is commented and easy to understand:
Remstart **************************************
Crystal Collect
Codeing by: THE WISE YODA
Just a simple program to randomly generate
crystals, then have a character be able to pick
them up and earn points. Will add animation to
them later
**************************************** Remend
Rem Setup screen and all that nasty stuff
Set Display Mode 800,600,16
Sync Rate 0 : Sync On : Sync Rate 60
Hide Mouse : Autocam Off
Backdrop on : color backdrop rgb(0,0,0)
Rem Make Variables/Types/Arrays
Rem Define some Variables
total = 20 ` = how many crystals we are giong to have
your_points = 0
Rem I'll define the Crystal Type here
Type Crystal
amount as integer
statues as integer
x as integer
z as integer
EndType
Rem Now i'll define the Crystal Array
Dim CrystalArray(total) as Crystal
Rem Now we'll give values to all the crystal variables and create our crystals and place them in world
For i = 1 to total
a = rnd(3)
if a = 1 then points = 10
if a = 2 then points = 25
if a = 3 then points = 100
CrystalArray(i).amount = points
CrystalArray(i).statues = 1 ` 1 = you can grab it / 0 = you've allready grabbed it
CrystalArray(i).x = 1000 - rnd(2000)
CrystalArray(i).z = 1000 - rnd(2000)
Make Object sphere i+50,30,2,4
if a = 1 then color object i+50,rgb(255,0,0)
if a = 2 then color object i+50,rgb(0,255,0)
if a = 3 then color object i+50,rgb(0,0,255)
position object i+50,CrystalArray(i).x,15,CrystalArray(i).z
Next i
Rem Make a character model to move around
Make Object Cube 1,20
Color Object 1,rgb(150,100,200)
Position object 1,0,10,0
Rem Make simple terrain
Make Matrix 1,2000,2000,20,20
Set Matrix Wireframe on 1
position matrix 1,-1000,0,-1000
Rem Main loop
Do
Rem Print score on screen
Set Cursor 0,0
Print "Your Score Is: ";your_points
Rem Do Some Character Movement and control camera
If Upkey() = 1 then Move Object 1,5
If Downkey() = 1 then Move Object 1,-5
ya = Object angle Y(1)
If Leftkey() = 1 then yrotate object 1,wrapvalue(ya-3)
If Rightkey() = 1 then yrotate object 1,wrapvalue(ya+3)
Set Camera to Follow object position x(1),0,object position z(1),ya,200,75,5,0
Rem Check to see if your character hits a crystal, and do that thing
for i = 1 to total
if CrystalArray(i).statues = 1
if object position x(1) > CrystalArray(i).x - 25
if object position x(1) < CrystalArray(i).x + 25
if object position z(1) > CrystalArray(i).z - 25
if object position z(1) < CrystalArray(i).z + 25
hide object i+50
your_points = your_points + CrystalArray(i).amount
CrystalArray(i).statues = 0
Endif
Endif
Endif
Endif
Endif
next i
Sync
Loop