TGC Codebase Backup



3D Ball Move by Charlie

30th Dec 2005 0:37
Summary

Little example of a moving ball with rotation and 3D effect. You control the ball with the arrows. Actualized with image.



Description

This is my first project. Here, you control a ball that advances and reverses with up and down arrow keys and rotates with the left and right arrows. I will be improving it.I have actualized it and textured the ball with an image.Put the image in the game folder for it to work.If you don't put the image the gamce can work, but the ball won't have texture.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    REM * 3D Ball Move v. 1.0 *
REM Created by Gamekids

rem basic set
position camera x,y,z
hide mouse
gosub _printtext
gosub _createball
sync on

rem print some text info
_printtext:
print "3D Ball Move v. 1.0"
print "Created by Gamekids"
print "Use arrows to move. Left and right to rotate ball. Up and down to"
print "move ball foward or reverse"
print "Press enter if you lose the ball"
print "Press Esc to exit"
wait key
return

rem create ball
_createball:
make object sphere 1,1
if file exist("anf_gamesicon2_copy.bmp") then load image "anf_gamesicon2_copy.jpg",1
if image exist(1) then texture object 1,1 else color object 1,rgb(50,00,255)
gosub _ballcontrol
return

rem ball controls
_ballcontrol:
do
if upkey()=1 then move object 1,0.1
if downkey()=1 then move object 1,-0.1
if leftkey()=1 then yrotate object 1,object angle y(1)-1
if rightkey()=1 then yrotate object 1,object angle y(1)+1
if keystate(28)=1 then position object 1,x,y,z
loop
return