Hi,
i have just finished my first game (if you can call it that). This is the code. BTW It;s written in DBC!!!
hide mouse:sync rate 40
rem create matrix and texture it
make matrix 1,1000,1000,50,50
load image "tarmac05.bmp",1
Prepare matrix texture 1,1,1,1
Fill matrix 1,0,1
randomize matrix 1,15
position matrix 1,0,0,0
rem turn on fog and backdrop
Load image "stars.bmp",4
backdrop on:texture backdrop 4
Fog on:fog color rgb(150,0,0)
rem create and texture player/ball
load image "iron01.bmp",2
make object sphere 1,100
texture object 1,2
rem load texture for small balls
Load image "bright01.bmp",3
rem make 20 balls and place them randomly
rem texture balls and set collision
make object sphere 100,25
position object 100, rnd(1000),30, rnd(1000)
texture object 100,3
rem set the value of the points
points#=0
a=1000
pos#=500
pos1#=500
speed#=10
rem *Main Loop*
sync on:DO
milsec# = milsec#+1
IF milsec# = 40
sec# = sec#+1
milsec# = 0
IF sec#>40 THEN wait 3500 : END
ENDIF
SET CURSOR 20,25
PRINT "TIME ";sec#
SET CURSOR 150,10
PRINT "YOU HAVE 40 SECONDS TO COLLECT THE BALLS"
rem Detect collision and delete spheres
If object collision(1,100)=1
position object 100, rnd(1000),30, rnd(1000)
points#=points#+1
speed#=speed#+2
endif
rem print the points in the top left of the screen
set cursor 20,10:print "SCORE ";points#
rem stop the game and play anim when points equal 20
IF points#=20
delete object 100
wait 3500
end
endif
rem setup player/ball movement
IF upkey()=1 and pos1#<950 then pos1#=pos1#+speed#
IF downkey()=1 and pos1#>50 then pos1#=pos1#-speed#
IF leftkey()=1 and pos#>50 then pos#=pos#-speed#
IF rightkey()=1 and pos#<950 then pos#=pos#+speed#
rem position ball and camera
position object 1,pos#,get ground height(1,pos#,pos1#)+50,pos1#
position camera pos#,150,pos1#-350
sync:Loop
The idea is the collect the smaller balls with the bigger ball. It's my first game so it is going to be pants, but a few comments would be nice.
Cheers
Jozers
BTW all media can be found on the darkBasic media browser.