Well, with nothing on the TV and all my social networking games all done and dusted and a few hours left before I even thought about going to bed I decided to do a 3D'ish copy of a very simple effect from the old Atari ST and Amiga days.
No media required...
Here's the code and I hope it's readable:
SET BITMAP FORMAT 21 : AUTOCAM OFF : SYNC ON : SYNC RATE 0 : SYNC
` tex_size is the image size width and height of the texture
` I've had to make it small to run smooth on my low end lappy
` tex_gap defines the size of the circles radius
#CONSTANT tex_size = 128
#CONSTANT tex_gap = 8
` plane_size is the complete dimension width and height of the object plane
` plane_scale is how many times the texture is repeated across and down
#CONSTANT plane_size = 2000
#CONSTANT plane_scale = 20
` cam_ang1-3 are then current angles controlling the camera movement
` cam_spd1-3 sets the movement speed of the camera around its radius
` cam_rad1-3 are the radii of the movement
` cam_dst is the distance away from the main objects
GLOBAL cam_ang1# = 0
GLOBAL cam_ang2# = 0
GLOBAL cam_ang3# = 0
#CONSTANT cam_spd1 = 0.96
#CONSTANT cam_spd2 = 1.45
#CONSTANT cam_spd3 = 3.5
#CONSTANT cam_rad1 = 50.0
#CONSTANT cam_rad2 = 45.0
#CONSTANT cam_rad3 = 50.0
#CONSTANT cam_dst1 = -150.0
` set_max is the amount of (3) sets of objects that will be used
` set_dst is the distance between each plane on the screen
` set_rad is the movement radius when in motion
#CONSTANT set_max = 4
#CONSTANT set_dst = 50
#CONSTANT set_rad = 180.0
` These are used for delta timing to keep the movement smooth no matter
` what computer this is running on.
` time_del# is the multiplier used to control delta movement
GLOBAL time_old
GLOBAL time_new
GLOBAL time_del#
` For each plane on the screen (angle, speed and z position)
TYPE set_defs
ang#
spd#
pos#
ENDTYPE
` The main array to hold all the above TYPE details for every plane
GLOBAL DIM sets(set_max,3) AS set_defs
` Setup the main data before going into the main loop
create_textures()
create_plain_objects()
create_lights()
` Erm, dunno what this does... ;-)
COLOR BACKDROP 0
` Refresh the global timer value before starting
time_old = TIMER()
` The main loop
REPEAT
get_delta() ` Update the delta TIMER value
do_camera() ` Move the camera
do_sets() ` Controls the movement of the plane objects
TEXT 0,0,"FPS:"+STR$(SCREEN FPS()) ` Show the user the current FPS
SYNC
UNTIL SPACEKEY()
END
` -------------------------------------------
` Gets the new multiplier for movement in time_del#
` I've used 33.0 as it helped keep my old values normal before I added this in
FUNCTION get_delta()
time_new = TIMER()
time_del# = ( time_new - time_old )
time_del# = time_del# / 33.0
time_old = time_new
ENDFUNCTION
` Animates all the plane objects on the screen
FUNCTION do_sets()
LOCAL set
LOCAL cob
LOCAL curr = 1
LOCAL x AS float
LOCAL y AS float
LOCAL z AS FLOAT
LOCAL del_spd#
FOR set = 1 TO set_max
FOR cob = 1 TO 3
x = SIN(sets(set,cob).ang#) * set_rad
y = COS(sets(set,cob).ang#) * set_rad
z = sets(set,cob).pos#
POSITION OBJECT curr,x,y,z
del_spd# = time_del# * sets(set,cob).spd#
sets(set,cob).ang# = WRAPVALUE( sets(set,cob).ang# + del_spd# )
INC curr
NEXT cob
NEXT set
ENDFUNCTION
` animates the camera
FUNCTION do_camera()
LOCAL x AS FLOAT
LOCAL y AS FLOAT
LOCAL z AS FLOAT
LOCAL spd1#
LOCAL spd2#
LOCAL spd3#
x = COS(cam_ang1#) * cam_rad1
y = SIN(cam_ang1#) * cam_rad1
z = COS(cam_ang3#) * cam_rad3 + cam_dst1
POSITION CAMERA x,y,z
POINT CAMERA COS(cam_ang2#) * cam_rad2,sin(cam_ang2#) * cam_rad2,0
POSITION LIGHT 1,x,y,z
spd1# = cam_spd1 * time_del#
spd2# = cam_spd2 * time_del#
spd3# = cam_spd3 * time_del#
cam_ang1# = WRAPVALUE(cam_ang1# + spd1#)
cam_ang2# = WRAPVALUE(cam_ang2# + spd2#)
cam_ang3# = WRAPVALUE(cam_ang3# + spd3#)
ENDFUNCTION
` create some of our own media
FUNCTION create_textures()
LOCAL tex_half
LOCAL tex_max
LOCAL tex_rad
tex_half = tex_size / 2
tex_max = tex_size - 1
tex_rad = tex_half - tex_gap
` make red circle
CLS
A2FILLCIRCLE tex_half,tex_half,tex_half,0xffff0000
A2FILLCIRCLE tex_half,tex_half,tex_rad,0xff000000
GET IMAGE 1,0,0,tex_max,tex_max,0
` green circle
CLS
A2FILLCIRCLE tex_half,tex_half,tex_half,0xff00ff00
A2FILLCIRCLE tex_half,tex_half,tex_rad,0xff000000
GET IMAGE 2,0,0,tex_max,tex_max,0
` blue circle
CLS
A2FILLCIRCLE tex_half,tex_half,tex_half,0xff0000ff
A2FILLCIRCLE tex_half,tex_half,tex_rad,0xff000000
GET IMAGE 3,0,0,tex_max,tex_max,0
CLS
SYNC
ENDFUNCTION
` create all the plane object and set their textures
` This also sets up the array with the plane movement values
FUNCTION create_plain_objects()
LOCAL cob
LOCAL dist
LOCAL set
FOR set = 1 TO set_max
cob = (set-1)*3+1
dist=(set-1)*(3*set_dst)
` first object
MAKE OBJECT PLANE cob,plane_size,plane_size
TEXTURE obJECT cob,1
SCALE OBJECT TEXTURE cob,plane_scale,plane_scale
POSITION OBJECT cob,0,0,dist
SET OBJECT TRANSPARENCY cob,3
` second object
MAKE OBJECT PLANE cob+1,plane_size,plane_size
TEXTURE OBJECT cob+1,2
SCALE OBJECT TEXTURE cob+1,plane_scale,plane_scale
POSITION OBJECT cob+1,0,0,dist+set_dst
SET OBJECT TRANSPARENCY cob+1,3
` third object
MAKE OBJECT PLANE cob+2,plane_size,plane_size
TEXTURE OBJECT cob+2,3
SCALE OBJECT TEXTURE cob+2,plane_scale,plane_scale
POSITION OBJECT cob+2,0,0,dist+(set_dst*2)
set OBJECT TRANSPARENCY cob+2,3
` setup set data
sets(set,1).ang# = 0.0
sets(set,1).spd# = set * 0.2 + 1.0
sets(set,1).pos# = dist
sets(set,2).ang# = 0.0
sets(set,2).spd# = set * 0.25 + 1.0
sets(set,2).pos# = dist + set_dst
sets(set,3).ang# = 0.0
sets(set,3).spd# = ( set + 1 ) * 0.25 + 1.0
sets(set,3).pos# = dist + set_dst + set_dst
next set
ENDFUNCTION
` Just using a single light because the planes are not detailed enough
` to display a decent lighting effect.
FUNCTION create_lights()
MAKE LIGHT 1
POSITION LIGHT 1,0,0,-250
`MAKE LIGHT 2
`POSITION LIGHT 2,0,150,-100
`COLOR LIGHT 2, 0xffff00
ENDFUNCTION
Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!