OK, I just got around to trying to put your code into mine and it would not work. Im not even sure if i did it right at all.
Rem Sets up Sync rate and hides mouse
Sync on
Sync Rate 40
Hide Mouse
Rem Loads Media For Game
Load Image "mediastars.bmp", 1
Load Image "mediaship.jpg", 2
Load Image "mediagreenlazer.jpg", 3
Load Image "mediaenemy1.jpg", 4
Load Image "mediashipup.jpg", 5
Load Image "mediashipdown.jpg", 6
Load Image "mediaflame.bmp",7
Load sound "mediaphaser03.wav", 1
Load sound "mediaboom2.wav", 2
Rem Variables
pf = 0
ysx = 50
ysy = 200
shoot = 0
bomb = 0
esx = 400
esy = 150
bleft = 3
Rem Creates The background and Positions it
Make Object Plain 1, 600, 100
Position Object 1, 0, -4, 70
Rem Textures the background object and locks it on screen
Texture Object 1, 1
Lock Object on 1
Rem places ship on screen
Sprite 1, ysx, ysy, 2
Rem Places First Enemy Ship on screen
Sprite 3, esx, esy, 4
TYPE 2dPoint
x as integer
y as integer
ENDTYPE
TYPE Enemy
Pos as 2dPoint
Goal as 2dPoint
Step as 2dPoint
rem OTHER STUFF HERE
ENDTYPE
rem MAKE THE ARRAY
dim Enemies(15) as ENEMY
for a 1 to 15: InitEnemies(a): next a
Rem Main Loop
Do
rem BASIC ENEMY LOOP
for i=1 to 15
MoveEnemy(i)
DrawEnemy(i) : rem MAKE THIS COMMAND YOURSELF BASED ON POS.x POS.y
next i
Rem refreshes sprite
If Upkey() = 0 And Downkey() = 0
Sprite 1, ysx, ysy, 2
Endif
Rem goes to bleft subroutine
Gosub bleft:
Rem Goes to scroll back subroutine
Gosub scrollback:
Rem Goes to moveup subroutine
Gosub moveup:
Rem Goes to movedown subroutine
Gosub movedown:
Rem Goes to moveforward subroutine
Gosub moveforward:
Rem Goes to moveback subroutine
Gosub moveback:
Rem Goes to shoot subroutine
Gosub shoot:
Rem Goes to bomb subroutine
Gosub bomb:
Rem Goes to hitlaser subroutine
Gosub hitlaser:
Rem Goes to hitbomb subroutine
Gosub hitbomb:
Sync
Loop
Rem Places and refreshes number of bombs on screen.
bleft:
Ink RGB(255,255,255),RGB(0,0,0)
Center Text 590,450,"Bombs: " + str$(bleft)
INK RGB(0,0,0),RGB(255,255,255)
Return
Rem Scrolls the star background
scrollback:
Scroll Object Texture 1, 0.008, 0.0
Return
Rem Moves ship up if Up key is pressed
moveup:
If Upkey() = 1 and ysy > 0
Dec ysy, 10
Sprite 1, ysx, ysy, 5
Endif
Return
Rem Moves ship down if Down key is pressed
movedown:
If Downkey() = 1 and ysy < 430
Inc ysy, 10
Sprite 1, ysx, ysy, 6
Endif
Return
Rem Moves ship forward if Right key is pressed
moveforward:
If Rightkey() = 1 and ysx < 150
Inc ysx, 10
Endif
Return
Rem Moves ship backwards if Left key is pressed
moveback:
If Leftkey() = 1 and ysx > 0
Dec ysx, 10
Endif
Return
Rem Controls displays laser and shoots
shoot:
Rem Creates Variables for laser
If shoot = 0
lx = sprite x (1) + 35
ly = sprite y (1) + 29
Endif
Rem Displays Laser
If Spacekey() = 1 and shoot = 0
Shoot = 1
Sprite 2, lx, ly, 3
play sound 1
Endif
Rem Moves Laser accross screen
If sprite exist(2) = 1
If Sprite X(2) < 639
lx = lx + 45
Sprite 2, lx, ly, 3
Endif
IF Sprite X(2) > 639
Sprite 2, 700, 480, 3
Shoot = 0
Endif
Endif
Return
bomb:
Rem Creates Variables for Bomb
If bomb = 0
bx = sprite x (1) + 45
by = sprite y (1) + 5
Endif
Rem Displays Bomb
If shiftkey() = 1 and bomb = 0 and bleft > 0
bomb = 1
bleft = bleft - 1
If bleft < 0
bleft = 0
Endif
sprite 4, bx, by, 7
Endif
Rem Moves bomb across screen
If Sprite exist(4) = 1
If sprite X(4) < 639
bx = bx + 35
sprite 4, bx, by, 7
Endif
If Sprite X(4) > 639
Sprite 4, 700, 480,7
bomb = 0
Endif
Endif
Return
hitlaser:
If shoot = 1 and sprite exist(2) = 1
If Sprite Hit(2,3) = 1
Sprite 2, 700,480, 3
Sprite 3, 700, 480, 4
shoot = 0
Play Sound 2
Endif
Endif
Return
hitbomb:
If bomb = 1 and sprite exist (4) = 1
If Sprite Hit (4,3) = 1
Sprite 4, 700, 480,7
Sprite 3, 700, 480,4
bomb = 0
Endif
Endif
Return
end
rem Always good to include an END statment even if you never
rem reach it. All function declarations need to appear at the
rem end of the program.
rem Simple Init Code, change to your liking
function InitEnemies(num as integer)
rem RANDOM START POSITION
Enemies(num).Pos.x = rnd(640)
Enemies(num).Pos.y = rnd(480)
rem RANDOM GOAL POSITION
Enemies(num).Goal.x = rnd(640)
Enemies(num).Goal.y = rnd(480)
rem How far to move each loop
Enemies(num).Step.x = (Enemies(num).Goal.x - Enemies(num).Pos.x) / 15
Enemies(num).Step.y = (Enemies(num).Goal.y - Enemies(num).Pos.y) / 15
rem OTHER INIT CODE HERE IF YOU NEED IT
endfunction
rem MOVE AN ENEMY!
function MoveEnemy(num as integer)
inc Enemies(num).Pos.x, Enemies(num).Step.x
inc Enemies(num).Pos.y, Enemies(num).Step.y
rem add collision checks here and update flags
endfunction
rem DRAW AN ENEMY!
function DrawEnemy(num as integer)
rem display/position/animation code goes here
endfunction
When i try to compile it, it says it could not understand for statement at line 61
I know that i probably did this completely wrong.
Im also having trouble with types. What are they and what do they do?
-AJay-
Thanks
P4 3.2GHZ, 256MB DDR Ram, 64MB NVidea G-Force 4, Sound Blaster Live, 40 Gig HD Thanks to Coding Area