okay, I am still stuck, as to what ways i need to use to get sprites to move once they have been drawn. currently, I can get them to move after their drawn by doing movesprite 30,-2, movesprite 31,-2 etc over and over for each enemy but this gets very repetative. is there a way to link certain sprites into a group, and just move the group associate dwith the sprites for easy handling and manipulation?
Iv included my code in the snippet hopefullly it will display right.
REM Project: ship
REM Created: 10/11/2005 12:02:49 PM
REM
REM ***** Main Source File *****
REM
sync on
sync rate 45
`load images neccisary for sprites
LOAD IMAGE "ship1.bmp",1
Load image "laser.bmp",2
Load image "spaceinvader1.bmp",4
Load image "spaceinvader2.bmp",5
Load image "spaceinvader3.bmp",6
Load image "explosion1.bmp",7
Load image "explosion2.bmp",8
Load image "explosion3.bmp",9
Load image "explosion4.bmp",10
load image "starfield.bmp",11
paste image 11,0,0
`declare all needed variables
starfielddrawon = 0
lasernum = 10
laserwait = 1000 `number of seconds of cooldown between each fire
maxnumoflasers = 5
laser = 10
l=10
maxlife = 100
Dim lasershoots(5)
invadernumber=30
indexnum=1
wave#=1
waveinitilization = 1
lives = 3
score = 0
invaderlasercounter = 0
invader = 30
varenemy = 0
invadernum = 30
inv = 30
`hide the mouse
hide mouse
if starfielddrawon = 1 then gosub stars else gosub main
`stars subrotine
stars:
for starfield = 1 to 325
`assign a random number to starx and stary, 325 times
starx = RND(640)
stary = RND(480)
`draw the (random) stars, 100 times
dot starx,stary
`throw a switch, making it so that this starfield draw will happen ONLY ONCE
sync
next starfield
`--------------------START OF NEW LEVEL VARIABLE-------------------------------------------------------
new_game:
level=0
lives=3
score=0
`invader speed must be - (as it moves down using the MOVE SPRITE command)
`------------------------------------------------------------------------------------------------------
`--------------LEVEL 1 VARIABLES--------------------------------------------------------------------------
new_game_level:
destroyed=0
explode=0
fire=0
invaderspeed = -1
fire = 0
offsetx = 5
offsety= 5
speed=2
movex=1
inc fighterspeed
offsetx = 30
offsety = 50
`---------------------------------------------------------------------------------------------------------
main:
`----------------------------------------------------------------------------------------------------
`get the screen area, "capturing" the stars, and saving + loading them as valid image file
get image 3,0,0,640,480,1
save image "starfield.bmp",3
Load image "starfield.bmp",3
spaceshipx = 400
spaceshipy = 400
wave#=1
`start the main loop
do
`clear the screen
sync
`-------------------subroutine calls------------------------
gosub laser
if wave#=1 then gosub invaders
`----------------------------------------------------------------------
`declare width,height and depth as valid varaibles for actual screen area
width = screen width()
height = screen height()
depth = screen depth()
`create the permenent starfield
paste image 3,0,0
`eliminate the blue background syndrom
SET SPRITE 1,0,0
sprite 1,spaceshipx,spaceshipy,1
`define movement keys for ship(player)
if leftkey()=1 then dec spaceshipx,1
if rightkey()=1 then inc spaceshipx,1
if upkey()=1 then dec spaceshipy,1
if downkey()=1 then inc spaceshipy,1
`---define screen border boundary---
`left screen border
if spaceshipx < 0 then inc spaceshipx,1
`right screen border
if spaceshipx > 612 then dec spaceshipx,1
`bottom screen border
if spaceshipy > 452 then dec spaceship,1
`screen border of top (roguhly 200 pixels up from bottom of sreen, as in spaceinvanders)
if spaceshipy < 400 then inc spaceshipy,1
`if sprite exist(invadernum) then move sprite invadernum,-2
move sprite `no idea how to move sprites especially many of them at once!! HELP!=)
loop
laser:
`check if the user is pressing space AND the delay between shots has been met
if spacekey()=1 and (timer()-lastcreated) > laserwait
`create a delay between shots, to prevent rapid fireing
lastcreated = timer()
`draw the initial sprite
sprite l,spaceshipx,spaceshipy,2
`increment the sprite drawe so a new laser is drawn each time
l = l + 1
endif
`Move the sprite as soon as it is created & delete it if it goes off the screen
if sprite exist(10)
move sprite 10,3
if sprite Y(10)<= -40 then delete sprite 10
endif
`Move the sprite as soon as it is created & delete it if it goes off the screen
if sprite exist(11)
move sprite 11,3
if sprite Y(11)<= -40 then delete sprite 11
endif
`Move the sprite as soon as it is created & delete it if it goes off the screen
if sprite exist(12)
move sprite 12,3
if sprite Y(12)<= -40 then delete sprite 12
endif
`Move the sprite as soon as it is created & delete it if it goes off the screen
if sprite exist(13)
move sprite 13,3
if sprite Y(13)<= -40 then delete sprite 13
endif
`Move the sprite as soon as it is created & delete it if it goes off the screen
if sprite exist(14)
move sprite 14,3
if sprite Y(14)<= -40 then delete sprite 14
endif
`reset sprite drawer to 10, so it mimics a loop, with a bit of customization
If l = 15 then l = 10
return
invaders:
`default values for sprites/images to be used... important!
imagenuminvader = 6
`set up invaders
for wave1setup = 1 to 14
invadernum = invadernum + 1
`set up spacing between invaderes
offsety = 5
offsetx = offsetx + 40
`draw invaders
sprite invader,offsetx,offsety,imagenuminvader
`counter for invaders, used to determine sprite and image numbers
imagenuminvader = imagenuminvader + 1
if imagenuminvader = 7 then imagenuminvader = 4
inc invader,1
next wave1setup
dec invader,1
wave#=0
return