Ive made some functions for beginners to help them with their game. Ill explain them here, I will add more functions when I got time.
Figure(int x,int y,int sides,int size,int rotate)
Draws n-gons. Kinda slow with big figures, so its best
when used in 2D.
x and y are the screen coordinates.
sides = amount of lines your figure should have (triangle = 3)
size = size of each line
rotate = rotate the figure
Multi_figure(amount-of-points)
Draws lines between given coordinates. The coordinates should be
in an array (
MUFIG_POINTS(amount,1) )
You can manually input the coordinates, or use random, example:
for fill=0 to amount
MUFIG_POINTS(fill,0)= rnd(640)
MUFIG_POINTS(fill,1)= rnd(480)
next fill
Distance(object one, object two)
Calculates the distances and returnes it (real/float number)
Camera_set_follow(object,distance_to_object#,rotate_camera#,height#)
Puts the camera behind the object.
Distance_to_object#=How far should the camera stay behind the object?
rotate_camera#=Rotates the camera, example:
0.0
270.0 PLAYER 90.0
180.0
Thats it, just copy those functions to your program and they should work (dont forget the array for multi_figure)
If you want an example, then remove the REMSTART and REMEND for the 2D OR 3D loop. And remove the REM in the DO LOOP for a little demonstration of the function.
sync on
sync rate 0
remstart
Figures:
Figure(x,y,sides,size,rotate)
Draws n-gons, between 2 and 300
Multi_figure(amount-of-points)
mirror = 1 will vertically mirror the figure
flip = 1 will horizontally flip the figure
REQUIRES ARRAY MUFIG_POINTS(amount,1)
for fill=0 to amount
MUFIG_POINTS(fill,0)= X
MUFIG_POINTS(fill,1)= Y
next fill
3D Math:
Distance(object_one,object_two) : RETURNS DISTANCE#
Gets the distance between 2 points in 3D space. And Fast!
Camera_set_follow(object,distance_to_object#,rotate_camera#,height#)
Puts the camera (and follows) behind an object in 3D space, rotate only works on Y angle (usefull for camera action shots)
remend
rem Do you want to rotate the figure, then adjust this number (degrees, between 0 and 360)
rotate = 180
rem For Figure
sides = 5
rem For Multi_Figure
dim MUFIG_POINTS(20,1)
for a=0 to 20
MUFIG_POINTS(a,0)=rnd(200)+320
MUFIG_POINTS(a,1)=rnd(200)+240
next a
rem Do loop for 2D
remstart
do
cls
ink rgb(255,255,255),0
rem Remove rem to call them
rem figure(320,240,sides,200,rotate)
rem Multi_figure(20)
sync
loop
remend
rem Do Loop for 3D
remstart
backdrop on
make object cube 1,10
make object cube 2,10
position object 1,20,100,210
do
rem Remove rem to call them
rem text 5,10,str$(distance(1,2))
rem if upkey()=1 then rotate_camera#=wrapvalue(rotate_camera#+1)
rem camera_set_follow(1,200.0,rotate_camera#,20.0)
rem point camera object position x(1),object position y(1),object position z(1)
sync
loop
remend
function figure(x,y,sides,size,rotate)
steps=360/sides
current_step=0
while current_step <> 360
line x+sin(current_step+rotate)*size,y+cos(current_step+rotate)*size,x+sin(current_step+steps+rotate)*size,y+cos(current_step+steps+rotate)*size
current_step=current_step+steps
endwhile
endfunction
function multi_figure(amount)
buffer=0
while buffer <> amount-1
line MUFIG_POINTS(buffer,0),MUFIG_POINTS(buffer,1),MUFIG_POINTS(buffer+1,0),MUFIG_POINTS(buffer+1,1)
inc buffer
endwhile
line MUFIG_POINTS(buffer,0),MUFIG_POINTS(buffer,1),MUFIG_POINTS(0,0),MUFIG_POINTS(0,1)
endfunction
function distance(one,two)
x#=object position x(one)
xx#=object position x(two)
y#=object position y(one)
yy#=object position y(two)
z#=object position z(one)
zz#=object position z(two)
distance#=sqrt( (x#-xx#)^2+(y#-yy#)^2+(z#-zz#)^2)
endfunction distance#
function camera_set_follow(object,distance#,rotate#,height#)
position camera object position x(object)+(sin(object angle y(object)+rotate#)*distance#),height#,object position z(object)+(cos(object angle y(object)+rotate#)*distance#)
endfunction
I'm busy making more functions, so hold on
Quote: "
Amd 2500+ | 1024mb pc2700 | A7N8X-X | Geforce4 ti 4200 128mb"