So I have been following AGK's tutorial videos on YouTube, and aside from changing the filenames to match my images/sound, I typed everything out correctly. However, in video 5 (Simple Shooter Part 2) I can only get the "laser" to activate the sound the first time it is fired, and that is all instead of playing every time it is fired. Not sure what I am doing wrong, so any help would be greatly appreciated. Below is my code thus far from following the videos instructions (again, only filename changes and I altered character position for the game I plan to build, just so you know).
===============
main.agc file
===============
SetVirtualResolution (768, 1024)
playerx as float
playery as float
vomitx as float = -100
vomity as float
vomit_launched = 0
score = 0
#include "Loader.agc"
#include "PlayerMove.agc"
#include "PlayerShoots.agc"
#include "Sounds.agc"
gosub loader
gosub PlayerMove
gosub PlayerShoots
gosub Load_Sounds
===============
loader.agc file
===============
oader:
LoadImage (1, "Player.png")
LoadImage (2, "Vomit.png")
CreateSprite (1, 1)
playerx = 380
playery = 0
SetSpritePosition (1, playerx, playery)
//Create vomit and move it off screen
CreateSprite (2,2)
SetSpritePosition (2, -100, -100)
Return
===============
playermove.agc file
===============
PlayerMove:
//Move the player in the X direction using GetDirectionX ()
playerx = playerx + GetDirectionX () * 12
//Check if the player is at left side of screen
if playerx < 0
playerx = 0
endif
//Check if the player is at right side of screen
if playerx > GetVirtualWidth () - GetSpriteWidth (1)
playerx = GetVirtualWidth () - GetSpriteWidth (1)
endif
//Set the player position
SetSpritePosition (1, playerx, playery)
Return
===============
playershoots.agc file
===============
PlayerShoots:
//Check if player has vomitted
if GetPointerPressed() = 1 and vomit_launched = 0
PlaySound (vomitlaunched)
vomit_launched = 1
vomitx = GetSpriteX (1) + GetSpriteWidth (1) /2 - GetSpriteWidth(2) /2
vomity = GetSpriteY (1) + 75
endif
//If vomit has been launched, move it down the screen
if vomit_launched = 1
vomity = vomity + 10
endif
//If the vomit has moved off screen, hide it
if vomity > 1024
vomit_launched = 0
endif
//Set the position of the vomit
SetSpritePosition (2, vomitx, vomity)
Return
===============
sounds.agc file
===============
Load_Sounds:
vomithit = LoadSound ("VomitHit.wav")
vomitlaunched = LoadSound ("VomitLaunch.wav")
Return