Hey Tony, i wrote this code up in a few minutes, i actually learned a few things too, but im also stumped,
you have to hold the space bar to make the ball move, but i was wondering if anyone knows how to make it be if you fire and forget, because the
if spacekey()=1
launch code
endif
you have to hold spacekey,
ill look more into it now but if anyone knows please post
if i find it out ill post it too
any way to the point , heres a simple Z coordinate launch code with angled trajectory, ill try and REM it later.
[EDIT]
okay i rem'd it and spaced it out
Rem Variables
power=1
n=1
Rem Refresh rate or FPS(frame rate)
sync on
sync rate 60
Rem Just to give a sense of depth
make matrix 1,100,100,10,10
Rem setup the camera in the top right corner
make camera 2
set camera view 2,0,0,200,200
set current camera 0
color backdrop 2,rgb(0,0,0)
Rem Main loop
do
Rem if there isnt an object 1 make an object 1
if object exist(1)=0
make object sphere 1,1
rem the starting angle of the projectile
rotate object 1,-45,0,0
endif
rem if there is an object one set the camera in the top right to follow it
if object exist(1)=1
set camera to follow 2,object position x(1),object position y(1),object position z(1),1,5,5,50,0
endif
rem if you press down the space key move and rotate a little bit at the same time
if spacekey()=1
xrotate object 1,object angle x(1)+1
move object 1, power
endif
rem if the object reaches a certain position delete it
if object position y(1) < -10
delete object 1
endif
rem just press these keys to make it go further before it dies
if upkey()=1
inc power
endif
if downkey()=1
dec power
endif
rem show the power level
text 0,10,"POWER:"+ STR$(power)
rem refresh
sync
loop
[EDIT]
okay new code with fire and forget
i put REM CHANGE on the parts i changed
basically make a variable 0
then set the variable to 1 if space bar is pressed
then when the object is deleted set the variable to 0
Rem Variables
power=1
n=1
Rem Refresh rate or FPS(frame rate)
sync on
sync rate 60
Rem Just to give a sense of depth
make matrix 1,100,100,10,10
Rem setup the camera in the top right corner
make camera 2
set camera view 2,0,0,200,200
set current camera 0
color backdrop 2,rgb(0,0,0)
fire = 0
Rem Main loop
do
Rem if there isnt an object 1 make an object 1
if object exist(1)=0
make object sphere 1,1
rem the starting angle of the projectile
rotate object 1,-45,0,0
endif
rem if there is an object one set the camera in the top right to follow it
if object exist(1)=1
set camera to follow 2,object position x(1),object position y(1),object position z(1),1,5,5,50,0
endif
rem if you press down the space key move and rotate a little bit at the same time
if spacekey()=1
fire = 1
endif
if fire = 1
xrotate object 1,object angle x(1)+1
move object 1, power
endif
rem if the object reaches a certain position delete it
if object position y(1) < -10
delete object 1
fire = 0
endif
rem just press these keys to make it go further before it dies
if upkey()=1
inc power
endif
if downkey()=1
dec power
endif
rem show the power level
text 0,10,"POWER:"+ STR$(power)
rem refresh
sync
loop
[EDIT]
okay just some timer based power increase
and a little update, just finished watchin that 70's show and im goin to bed
(Thanks to butter fingers for the timer help)
Rem Variables
power = 1
global timervar : timervar=0
Rem Refresh rate or FPS(frame rate)
sync on
sync rate 50
Rem Just to give a sense of depth
make matrix 1,100,100,10,10
Rem setup the camera in the top right corner
make camera 2
set camera view 2,0,0,300,300
set current camera 0
color backdrop 2,rgb(0,0,0)
fire = 0
oldy#= 0 REM CHANGED
st=timer()
Rem Main loop
do
Rem if there isnt an object 1 make an object 1
if object exist(1)=0
make object sphere 1,1
rem the starting angle of the projectile
rotate object 1,-45,oldy#,0
endif
rem if there is an object one set the camera in the top right to follow it
if object exist(1)=1
set camera to follow 2,object position x(1),object position y(1),object position z(1),object angle y(1),10,5,25,0
endif
rem if you press down the space key move and rotate a little bit at the same time
if spacekey()=1 REM CHANGED
fire = 1 REM CHANGED
endif REM CHANGED
if fire = 1 REM CHANGED
xrotate object 1,object angle x(1)+1 REM CHANGED
move object 1, power/4 REM CHANGED
endif REM CHANGED
rem if the object reaches a certain position delete it
if object position y(1) < -10
delete object 1
fire = 0
endif
rem just press these keys to make it go further before it dies
if upkey()=1 and timervar<timer()
inc power
timervar=timer()+400
endif
if downkey()=1 and timervar<timer()
dec power
timervar=timer()+400
endif
rem directional
if object exist(1)=1 and fire=0
if rightkey()=1
yrotate object 1,object angle y(1)+1
endif
if leftkey()=1
yrotate object 1,object angle y(1)-1
endif
oldy#= object angle y(1)
endif
if power < 4
power = 4
endif
if power > 8
power = 8
endif
rem show the power level
text 0,10,"POWER:"+ STR$(power)
loop
[edit]
i realized there was a problem in the code above so,
fixed:
Rem All by: kenny withrow AKA Master Man of Justice,and Thanks to TGC's Forum member : ButterFingers for a timer example :) help me with the power increase/decrease control
power = 1:
global timervar :
timervar=0:
sync on:sync rate 50:
fire=0:
oldy#=0
make matrix 1,100,100,10,10
:make camera 2
:set camera view 2,0,0,300,300
:set current camera 0
:color backdrop 2,rgb(0,0,0)
do
:text 300,10,"Press Up/down to increase power"
:Text 300,20,"Press left/right to rotate the sphere"
:text 300,30,"press space bar to launch"
:if object exist(1)=0
:make object sphere 1,1
:rotate object 1,-45,oldy#,0
:endif
:if object exist(1)=1
:set camera to follow 2,object position x(1),object position y(1),object position z(1),object angle y(1),10,5,25,0
:endif
:if spacekey()=1
:fire = 1
:endif:
if fire = 1
:xrotate object 1,object angle x(1)+1
:move object 1, power/4
:endif:if object position y(1) < -10
:delete object 1
:fire = 0
:endif
:if upkey()=1 and timervar<timer()
:inc power
:timervar=timer()+400
:endif
:if downkey()=1 and timervar<timer()
:dec power
:timervar=timer()+400
:endif
:if object exist(1)=1 and fire=0
:if rightkey()=1
:yrotate object 1,object angle y(1)+1
:endif
:if leftkey()=1
:yrotate object 1,object angle y(1)-1
:endif
:oldy#= object angle y(1)
:endif
:if power < 4:power = 4
:endif
:if power > 8:power = 8
:endif
:text 0,10,"POWER:"+ STR$(power)
:sync:loop
i still have to fix the power variable to a float because 4,5,6,7 are all the same power level because the power is divided by 4. and an integer wont work like that
[edit]
i dont know why but i have been stuck on this code like ugly on a gorilla. i just added more variable control and reset variable code pieces.
Im going to try to add bouncing on the matrix.
here
Rem All by: kenny withrow AKA Master Man of Justice,and Thanks to TGC's Forum member : ButterFingers for a timer example :) help me with the power increase/decrease control
power# as float
power# = 1.00
global timervar
timervar=0
sync on
sync rate 50
fire=0
oldy#=0
chosenarc# as float
chosenarc# = 1.00
chosenangle# = -45
make matrix 1,100,100,10,10
make camera 2
set camera view 2,0,0,300,300
set current camera 0
color backdrop 2,rgb(0,0,0)
do
text 300,10,"Press Up/down to increase power"
Text 300,25,"Press left/right to rotate the sphere"
text 300,40,"press space bar to launch"
text 300,55,"Press Shift/Ctrl to adjust angle : 0 = no curve 0 < increases in curve"
text 300,70,"Arc Amount:"+STR$(chosenarc#)
text 300,85,"Press R to delete the object"
text 300,100,"Press + or - to increase or decrease the angle"
text 300,115,"Angle:"+STR$(chosenangle#)
if object exist(1)=0
make object sphere 1,1
rotate object 1,chosenangle#,oldy#,0
endif
if object exist(1)=1
set camera to follow 2,object position x(1),object position y(1),object position z(1),object angle y(1),10,5,25,0
endif
if spacekey()=1
fire = 1
endif:
if fire = 1
xrotate object 1,object angle x(1)+chosenarc#+0.0
move object 1, (power#+0.00)/4
endif:if object position y(1) < -10
delete object 1
fire = 0
endif
if upkey()=1 and timervar<timer() and fire=0
inc power#,0.10
timervar=timer()+100
endif
if downkey()=1 and timervar<timer() and fire=0
dec power#,0.10
timervar=timer()+100
endif
if object exist(1)=1 and fire=0
if rightkey()=1
yrotate object 1,object angle y(1)+1
endif
if leftkey()=1
yrotate object 1,object angle y(1)-1
endif
oldy#= object angle y(1)
endif
if power# < 2:power# = 2.00
endif
if power# > 8.00:power# = 8.00
endif
if controlkey()=1 and fire = 0 and timervar<timer()
dec chosenarc#,0.1
timervar=timer()+100
endif
if shiftkey()=1 and fire = 0 and timervar<timer()
inc chosenarc#,0.1
timervar=timer()+100
endif
if chosenarc# < 0.0
chosenarc# = 0.0
endif
if chosenarc# > 5.0
chosenarc# = 5.0
endif
if keystate(19)=1
delete object 1
fire=0
endif
if keystate(13)=1 and timerval<timer()
inc chosenangle#
timervar=timer()+200
endif
if keystate(12)=1 and timerval<timer()
dec chosenangle#
timervar=timer()+200
endif
if keystate(47)=1
power#=2
chosenangle#=-45
chosenarc#=1
oldy#=0
fire=0
delete object 1
endif
text 0,10,"POWER:"+ STR$(power#+0)
sync
loop