I felt like going the route of 2D for a little while, see if my progess is better than in the 3D realm... well, it sure comes to me quicker [probably from my days programming stupid little graphical programs on my TI-83
]. Well, here is what I've come up with so far, but this will definantly progress into new variants as I work [you will need to download the .png image file in the DL below =) ]:
Rem Project: 2d test
Rem Created: 2/9/2005 7:34:50 PM
`---------------------------------
`Experimenting with 2D programming
`---------------------------------
set display mode 1280,1024,32
sync on
`main sprite
load image "1.png",1
sprite 1,0,0,1
set sprite priority 1,3
`sprite for testing collision
sprite 2,300,300,1
set sprite priority 2,1
`sprite for testing shadow
sprite 3,0,0,1
set sprite diffuse 3,0,0,0
set sprite alpha 3,100
set sprite priority 3,2
`I want the positions of the sprites to be oriented over their respective centers
offset sprite 1,int(sprite width (1)/2),int(sprite height (1)/2)
offset sprite 3,int(sprite width (3)/2),int(sprite height (3)/2)
`the movement and rotation variables
speed as float
rspeed as float
lspeed as float
direction as boolean
do
`All rotation is handled here
if keystate(32) = 1
direction = 1
rotate sprite 1,sprite angle(1)+rspeed
if rspeed <= 4 then rspeed = rspeed + .1
endif
if keystate(30) = 1
direction = 0
rotate sprite 1,sprite angle(1)-lspeed
if lspeed <= 4 then lspeed = lspeed + .1
endif
if keystate(32) = 0 and direction = 1
rotate sprite 1,sprite angle(1)+rspeed
if rspeed >= 0 then rspeed = rspeed - .1
endif
if keystate(30) = 0 and direction = 0
rotate sprite 1,sprite angle(1)-lspeed
if lspeed >= 0 then lspeed = lspeed - .1
endif
`All foreward movement is handled here
if keystate(17) = 1
move sprite 1,speed
if speed <= 10 then speed = speed + .1
endif
if keystate(17) = 0
move sprite 1,speed
if speed >= 0 then speed = speed - .1
endif
`Reset button... basically
if keystate(15) = 1 then sprite 1,0,0,1:rotate sprite 1,0
`I _don't_ need negative speed
if speed < 0 then speed = 0
if rspeed < 0 then rspeed = 0
if lspeed < 0 then lspeed = 0
`Placing the sprite I made earlier as a "shadow"
sprite 3,sprite x(1),sprite y(1)+30,1
rotate sprite 3,sprite angle(1)
`Testing out some circles to follow the ship's position and angle
cx = sprite x(1)
cy = sprite y(1)
angle = sprite angle(1)-90
offset = sprite height(1)
rot_x = offset*cos(angle) + cx
rot_y = offset*sin(angle) + cy
ink rgb(0,0,0),rgb(0,0,0)
circle cx,cy,100
circle rot_x,rot_y,50
display_info()
sync
loop
`Explains itself
function display_info()
set cursor 800,0
print "sprite overlap=",sprite collision(1,2)
set cursor 800,10
print "X=",sprite x(1)," Y=",sprite y(1)," Angle=",sprite angle(1)
set cursor 800,20
print "FPS=",screen fps()
endfunction
You can use the "w,a,s" keys to turn and push foreward, and the Tab button will reset you to the begining position. Tell me what you think...
-
Ignore the avatar...