#Constant sw = Screen Width()
#Constant sh = Screen Height()
rem The array parameters are: x position, y position, animation it is in
dim animdata(14,8,2)
sync on
sync
sync rate 0
hide mouse
disable systemkeys
savename$="CSIsaveGame"
print "Space Invaders"
print "by: Idiotic people"
print "(press any key to continue...)"
sync
wait key
cls
`Shape out the player with boxes
`(start at top of the ship And go down)
Box 12, 0, 14, 2
Box 10, 2, 16, 6
Box 2, 6, 24, 8
Box 0, 8, 26, 16
`Turn our graphic into an actual image
Get Image 1, 0, 0, 26, 16, 1
`Make a sprite of the image we just created And make it Green (like the retro days)
Sprite 1, -50, 0, 1
Set Sprite Diffuse 1, 0, 255, 0
`Create a 'bullet' sprite
Box 30, 30, 32, 46
Get Image 2, 30, 30, 32, 46
Type alien
xPos As Float
yPos As Float
color As DWord
firerate As Byte
MoveSpeed As Byte
EndType
ExitToMenu:
playerx# = 320
playery# = 400
NumOfAlienCols = 10
NumOfAlienRows = 5
Dim Enemies(NumofAlienRows, NumofAlienCols) As Alien
For row = 1 To NumOfAlienRows
For col = 1 To NumOfAlienCols
Enemies(row,col).xPos = (sw / 6) + (((((sw * 2)/3)) / NumOfAlienCols) * (col - 1))
Enemies(row,col).yPos = (sh / 4) + ((((sh /3)) / NumOfAlienRows) * (row - 1))
If col <= 2
`Load in the Alien Sprite, depending on the row.
LoadAliens(row + col + 100)
`Color's the alien according to the set color value, the sprite numbers range from 101 upward
Set Sprite Diffuse (row + col + 100),RGBR(Enemies(row,1).color),RGBG(Enemies(row,1).color),RGBB(Enemies(row,1).color)
endif
Next col
Next row
barrier1X=140
barrier1Y=310
barrier2X=300
barrier2Y=310
barrier3X=480
barrier3Y=310
fire = 0
score = 0
level = 1
lives = 3
timerFire=timer()
menu()
set text size 36
Repeat
`Loop speed regulation code, use loopSpeed# to regulate the speed of things
loopTime = timer()-lastTime
loopSpeed# = 1000.0/(1000.0/loopTime)
lastTime = timer()
center Text screen width() * .5,0, "SCORE<1> HI-SCORE SCORE<2>"
score1$ = STR$(score1)
For i = 0 To 4-Len(score1$)+1
score1$ = "0" + score1$
Next i
` just do the same For other scores
center Text screen width() * .5,36, score1$ + " " + hiscore$ + " " + score2$
`If bullet is inactive, then fire it If space is pressed
If not fire
If spacekey()
playerBulletX# = playerX# + 12
playerBulletY# = playerY# - 2
fire = 1
EndIf
Else
`If bullet is active then move it and show it as a sprite, also check if it goes off the screen
dec playerBulletY#,0.5*loopSpeed#
if playerBulletY# < -16 then fire = 0
sprite 2,playerBulletX#,playerBulletY#,2
EndIf
`Move player left and right with the arrow keys
inc playerx#,(keystate(205)-keystate(203))*loopSpeed#*0.3
`Limit player movement
If playerx# < 30 then playerx# = 30
If playerx# > 580 then playerx# = 580
If escapekey() = 1 then Goto ExitToMenu
`Draw player
sprite 1, playerx#, playery#, 1
sprite 10, 100, 100, 10
sync
cls
Until lives = 0
print "Game over"
print "Your score : " + str$(score)
print "Press spacebar to go to the menu, any other key to exit (and why would you want to do that?)"
sync
wait key
If spacekey() = 1 then Goto ExitToMenu Else End
function menu()
print "1.Start Game"
print "2.Load Game"
print "3.Help"
print "4.Exit"
`If inkey$()="1" then goto startgame
`If inkey$()="2" then loadgame()
endfunction
`---------------------
`-Functions-----------
`---------------------
`Load Game Function
`CSI = Community Space Invaders!
function loadgame(savename$)
If not file exist(savename$)
print "There is no Save Game data!"
print "(press ny key to continue)"
EndIf
endfunction
`Save Game Function
function savegame(savename$)
`We don't have any Data at the mo, so im leaving this blank.
endfunction
Function LoadAliens(sprtnum As Integer)
cls
If num = 1 : `if the alien to be loaded is in row number 1, then;
restore AlienAnimFrame1
for y = 1 to 8
for x = 1 to 14
read c
if c = 1 then dot x,y,rgb(100,100,255)
next x
next y
get image 10,1,1,15,8,1
restore AlienAnimFrame1
for y = 1 to 8
for x = 1 to 14
read c
if c = 1 then dot x,y,rgb(100,100,255)
next x
EndIf
cls
for y = 1 to 8
for x = 1 to 14
read c
if c = 1 then dot x,y,rgb(100,100,255)
next x
next y
get image 11,1,1,15,8,1
Endfunction
AlienAnimFrame1:
`rem alien Data To create sprite: animation frame 1
`Alien 1 Frame 1
`| #### |
`| ############ |
`|############## |
`|### ## ### |
`|############## |
`| ### ### |
`| ### ## ### |
`|## ## |
Data 0,0,0,0,0,1,1,1,1,0,0,0,0,0
Data 0,1,1,1,1,1,1,1,1,1,1,1,1,0
Data 1,1,1,1,1,1,1,1,1,1,1,1,1,1
Data 1,1,1,0,0,0,1,1,0,0,0,1,1,1
Data 1,1,1,1,1,1,1,1,1,1,1,1,1,1
Data 0,0,0,1,1,1,0,0,1,1,1,0,0,0
Data 0,0,1,1,1,0,1,1,0,1,1,1,0,0
Data 1,1,0,0,0,0,0,0,0,0,0,0,1,1
AlienAnimFrame2:
`rem alien Data To create sprite: animation frame 2
`Alien 1 Frame 2
`| #### |
`| ############ |
`|##############|
`|### ## ###|
`|##############|
`| ### ### |
`| ## ## ## |
`| ## ## |
Data 0,0,0,0,0,1,1,1,1,0,0,0,0,0
data 0,1,1,1,1,1,1,1,1,1,1,1,1,0
Data 1,1,1,1,1,1,1,1,1,1,1,1,1,1
Data 1,1,1,0,0,0,1,1,0,0,0,1,1,1
Data 1,1,1,1,1,1,1,1,1,1,1,1,1,1
Data 0,0,0,1,1,1,0,0,1,1,1,0,0,0
Data 0,0,1,1,0,0,1,1,0,0,1,1,0,0
Data 0,0,0,1,1,0,0,0,0,1,1,0,0,0
`Alien 2 Animation Frame 1
`| # # |
`|# # # #|
`|# ########## #|
`|### ###### ###|
`|##############|
`| ############ |
`| ## ## |
`| ## ## |
data 0,0,1,0,0,0,0,0,0,0,0,1,0,0
data 1,0,0,1,0,0,0,0,0,0,1,0,0,1
data 1,0,1,1,1,1,1,1,1,1,1,1,0,1
data 1,1,1,0,1,1,1,1,1,1,0,1,1,1
data 1,1,1,1,1,1,1,1,1,1,1,1,1,1
data 0,1,1,1,1,1,1,1,1,1,1,1,1,0
data 0,0,1,1,0,0,0,0,0,0,1,1,0,0
data 0,1,1,0,0,0,0,0,0,0,0,1,1,0
`Alien 2 Animation Frame 2
`| # # |
`| # # |
`| ########## |
`| ## ###### ## |
`|##############|
`|##############|
`|# ## ## #|
`| ## ## |
data 0,0,1,0,0,0,0,0,0,0,0,1,0,0
data 0,0,0,1,0,0,0,0,0,0,1,0,0,0
data 0,0,1,1,1,1,1,1,1,1,1,1,0,0
data 0,1,1,0,1,1,1,1,1,1,0,1,1,0
data 1,1,1,1,1,1,1,1,1,1,1,1,1,1
data 1,1,1,1,1,1,1,1,1,1,1,1,1,1
data 1,0,1,1,0,0,0,0,0,0,1,1,0,1
data 0,0,0,1,1,0,0,0,0,1,1,0,0,0
`Alien 3 Animation Frame 1
`| ## |
`| ###### |
`| ########## |
`|#### #### ####|
`|##############|
`| ## #### ## |
`| ## ## |
`|# #|
data 0,0,0,0,0,0,1,1,0,0,0,0,0,0
data 0,0,0,0,1,1,1,1,1,1,0,0,0,0
data 0,0,1,1,1,1,1,1,1,1,1,1,0,0
data 1,1,1,1,0,1,1,1,1,0,1,1,1,1
data 1,1,1,1,1,1,1,1,1,1,1,1,1,1
data 0,0,1,1,0,1,1,1,1,0,1,1,0,0
data 0,1,1,0,0,0,0,0,0,0,0,1,1,0
data 1,0,0,0,0,0,0,0,0,0,0,0,0,1
`Alien 3 Animation Frame 2
`| ## |
`| ###### |
`| ########## |
`|#### #### ####|
`|##############|
`| ## #### ## |
`| ## ## |
`| # # |
`Alien 3 Should be narrower than the first 2
`Therefore I propose the following frames
`[Proposed Narrower] Alien 3 Animation Frame 1
`| ## |
`| #### |
`| ###### |
`| ## ## ## |
`| ########## |
`| ## ## ## |
`| # # |
`| # # |
`[Proposed Narrower] Alien 3 Animation Frame 2
`| ## |
`| #### |
`| ###### |
`| ## ## ## |
`| ########## |
`| ## ## ## |
`| # # |
`| # # |
Completed the data for Alien 3 animation frame 1
and
inserted the rem
picture for animation frame 2
Also proposed using narrower animation frames for the 3rd alien.
As this is a communal project we need to decide which 3rd alien to use but traditionally the top alien (alien 3) is narrower and therefore more difficult to hit, which is why I made this proposal.
What do you think?