TGC Codebase Backup



a simple cube game by Nigel _Okgo

24th Oct 2006 16:13
Summary

a simple cube game, (no media required) code only.... the idea of the game is to keep both of the cubes centred on the screen, whilst moving them up and down as far as they can go



Description

the idea of the game is to keep both of the cubes centred on the screen,
whilst moving them up and down as far as they can go using the mouse....

you may find this quite fun....

my email address is michaelstephenrt@hotmail.com



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    randomize timer()

global song as integer

rem ****Rub Cubes****

rem you may want to include your own music....
rem you may find this game quite fun.... code only....

rem load music "music1.mid",1
rem load music "music2.mid",2

rem play music 1

start:

song=song+1
if rnd(2)=0 then goto after

rem if music playing(1)=1 then stop music 1
rem if music playing(2)=1 then stop music 2
rem if song=1 then play music 1
rem if song=2 then play music 2

after:
okgo=0
sync on
sync rate 32

cls rgb(0,0,255)

Rem Project: Other
Rem Created: 24/10/2006 20:09:02

Rem ***** Main Source File *****
` This code was downloaded from The Game Creators
` It is reproduced here with full permission
` http://www.thegamecreators.com

Global Variables
Global hAngle# As Integer
Global vAngle# As Integer
global score# as integer
global tmr as integer
global tmrgo as integer
global okgo as integer

hangle#=0
vangle#=0
score#=0
tmr=0
tmrgo=1000
okgo=0

`Set Sync, Load Objects
Sync Rate 0
Sync On

`Create the Main Character
if object exist(1)=0 then Make Object Cube 1, 100

`Only do this if your character is rotated incorrectly(like mine)
Rotate Object 1, Object Angle X(1), Object Angle Y(1) + 180, Object Angle Z(1)
Fix Object Pivot 1

`Load some 'scenery' so we know it's working
if object exist(2)=0 then Make Object Box 2, 200, 200, 200
Position Object 2, Object Position X(1) + 400, Object Position Y(1), Object Position Z(1)

Do

   `-Control Camera-
   `PARAMETERS:
   `Your Characters X Position, Char Y Position, Char Z Position, How far outwards the camera should be,
   `how high the camera should be (what the mouses Y is), how fast the cam moves around (how much the user moves their mouse), which camera
   MouseLook(Object Position X(1), Object Position Y(1), Object Position Z(1), 500.0, MouseMoveY(), MouseMoveX())


   Sync

Loop

Function MouseLook(xTarget, yTarget, zTarget, hDist#, vDist#, Speed#)

   `Continue from where we last were
   hAngle# = hAngle# + Speed#
   vAngle# = vAngle# + vDist#

   `Tricky part: Make a 'circular' camera movement
   xPos# = xTarget + cos(hAngle#) * hDist#
   yPos# = yTarget + vAngle#
   zPos# = zTarget + sin(hAngle#) * hDist#

   `Position Camera in it's new place and point it at our main character
   Position Camera xPos#, yPos#, zPos#
   Point Camera xTarget, yTarget, zTarget

   `Usually you'll want the camera just a tad higher then the char, so do that now
   Position Camera xPos#, yPos# + 200, zPos#

   `Point our Main Character in the same direction as our camera

ink rgb(255,255,0),rgb(255,255,0)

set text size 24
text 0,40,"Rub Cubes"

ink rgb(255,255,255),rgb(255,255,255)

set cursor 0,0
set text size 48
print score#
if tmrgo<100 then set text size 12
if tmrgo<100 then print ""
tmrgo=tmrgo-1
ink rgb(0,0,255),rgb(0,0,255)
if tmrgo<0 then tmrgo=0:set text size 32:ink rgb(0,255,255),rgb(0,0,255):center text 320,210,"Final Score "+str$(score#):okgo=okgo+1
if tmrgo<100 then print tmrgo

if okgo=100 then okgo=0:goto start

if vangle#>810 then vangle#=810
if vangle#<390 then vangle#=390
if hangle#>165 and hangle#<185 then if vangle#>800 then if tmr=0 and tmrgo>0 then tmr=1:score#=score#+10
if hangle#>165 and hangle#<185 then if vangle#<400 then if tmr=1 and tmrgo>0 then tmr=0:score#=score#+10

   Rotate Object 1, Object Angle X(1), Camera Angle Y(), Object Angle Z(1)

EndFunction