Hello, I have tried making the space shooter tutorial under RaspPi 3B and Arch with lxde DE, and I am at the MainMenu step and I encounter the "Error: Sprite 4 does not exist in mainmenu.agc at line XX" error, could somebody help me please?
Here are the main.agc content:
// Project: Engage
// Created: 2017-07-13
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "Engage" )
SetWindowSize( 600, 600, 0 )
SetWindowAllowResize( 0 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 600, 600 ) // doesn't have to match the window
UseNewDefaultFonts(1)
playerx as float
playery as float
lazerx as float = -100
lazery as float
lazer_fired = 0
enemyx as float
enemyy as float
enemy_direction = 4
enemy_fired=0
gameover=1
score=0
hiscore=0
#include "Loader.agc"
#include "PlayerMove.agc"
#include "Player_shoots.agc"
#include "enemy_move.agc"
#include "Collision.agc"
#include "stars.agc"
#include "Text.agc"
#include "sounds.agc"
#include "mainmenu.agc"
Gosub loader
Gosub Make_stars
Gosub Make_text
Gosub Load_sounds
Gosub Load_Music
do
if gameover=1
Gosub MainMenu
score=0
endif
Gosub PlayerMove
Gosub Player_shoots
Gosub Enemy_move
Gosub Enemy_Shoot
Gosub Move_stars
Gosub Collision
Sync()
loop
And the Loader.agc:
loader:
// Player Ship =1
// Player Lazer = 2
// Enemy Ship = 3
// Stars = 5 to 104
// Enemy Bullets = 110 to 114
loadimage(1,"player_ship.png")
loadimage(2,"lazer.png")
loadimage(3,"enemyship.png")
loadimage(4,"enemyfire.png")
// Create the player ship and place at the bottom of the screen
CreateSprite(1,1)
playerx=GetVirtualWidth()/2 - GetSpriteWidth(1)/2
playery=GetVirtualHeight()-GetSpriteHeight(1)
SetSpritePosition(1,playerx,playery)
//Create the lazer and move it off screen
CreateSprite(2,2)
SetSpritePosition(2,-100,-100)
// Create the enemy ship and place at the top of the screen
CreateSprite(3,3)
SetSpritePosition(3,100,20)
// Create 5 enemy bullets
for i=0 to 4
CreateSprite(110+i,4)
next i
Return
And finally the mainmenu.agc content:
MainMenu:
Createtext(2,"Engage")
SetTextSize(2,100)
SetTextPosition(2,(600-GetTexttotalwidth(2))/2,180)
Createtext(3,"High Score: ")
SetTextSize(3,60)
SetTextPosition(3,600-GetTexttotalwidth(3),0)
Createtext(4, "Fire to start game")
SetTextSize(4,60)
Settextposition(4,(600-GetTexttotalwidth(4))/2,400)
gosub Hidegamesprites
gosub showmenutext
repeat
sync()
until GetPointerPressed()=1
gameover=0
gosub Showgamesprites
gosub Hidemenutext
Return
// Player Ship =1
// Player Lazer = 2
// Enemy Ship = 3
// Stars = 5 to 104
// Enemy Bullets = 110 to 114
Hidegamesprites:
for i=1 to 114
SetSpriteVisible(i,0)
next i
Return
Showgamesprites:
for i=1 to 114
SetSpriteVisible(i,1)
next i
Return
Hidemenutext:
SetTextVisible(2,0)
SetTextVisible(4,0)
Return
Showmenutext:
SetTextVisible(2,1)
SetTextVisible(4,1)
Return
Thanks and cheers,