Code: Select all
@VERSION 10,0
@APPTITLE "First-Person Shooting Gallery Template"
@APPVERSION "$VER: FPS-Gallery v0.1"
@APPAUTHOR "OceanArts"
@APPCOPYRIGHT "CC0 - Creative Commons."
@APPDESCRIPTION "A starting point for a 2d first-person shooter type game.'"
@DISPLAY{WIDTH = 960, HEIGHT = 540, MODE = "FULLSCREEN", TITLE = "FPS-Gallery", COLOR = #BLACK}
; PRE-LOAD RESOURCES:
@BRUSH 1, "reticle.png", {LoadAlpha = True}
CreatePointer(1, #BRUSH, 1, 32, 22)
@BRUSH 2, "fps_hand.png", {LoadAlpha = True}
@BRUSH 3, "bkg_icftd.png"
@SAMPLE 1, "Slam.wav"
@SAMPLE 2, "EmptyMag.iff"
@SAMPLE 3, "GunReload.iff"
; SET SOME VARIABLES:
_is_firing = False
_bullets = 10
; FUNCTIONS:
Function p_MoveMouse()
If hand_x < 0 Then hand_x = 0
If hand_x > 960 Then hand_x = 960
DisplayBrush(2, hand_x - 80, 400)
; Handle mouse pointer if it moves outside window in windowed mode:
if MouseX() < 0 Then MovePointer(MouseX() + 8, MouseY())
if MouseX() > 960 Then MovePointer(MouseX() - 8, MouseY())
if MouseY() > 540 Then MovePointer(MouseX(), MouseY() - 8)
if MouseY() < 0 Then MovePointer(MouseX(), MouseY() + 8)
hand_x = MouseX()
EndFunction
Function p_Shoot()
_is_firing = True
If _is_firing = True and _bullets > 0
?PlaySample(1, {Volume = 18})
_bullets = _bullets - 1
Else
?PlaySample(2, {Volume = 10})
EndIf
EndFunction
Function p_StopShoot()
_is_firing = False
EndFunction
Function p_Reload()
?PlaySample(3, {Volume = 18})
_bullets = 10
EndFunction
Function p_HandlerFunc(msg)
Switch(msg.action)
Case "OnMouseMove":
p_MoveMouse()
Case "OnMouseDown":
p_Shoot()
Case "OnMouseUp":
p_StopShoot()
Case "OnRightMouseDown":
p_Reload()
EndSwitch
EndFunction
BeginDoubleBuffer()
EscapeQuit(True)
InstallEventHandler({OnMouseMove = p_MoveMouse, OnMouseDown = p_HandlerFunc, OnMouseUp = p_HandlerFunc, OnRightMouseDown = p_HandlerFunc})
; SOME INITIAL SET-UP:
SetFont(#SANS, 64)
SetPointer(1)
MovePointer(#CENTER, #CENTER)
; MAIN LOOP
Repeat
Cls()
If _bullets < 6 Then SetFontColor(#RED)
If _bullets > 6 Then SetFontColor(#LIME)
DisplayBrush(3, 0, 0)
Locate(8,8)
Print(_bullets)
p_MoveMouse()
Flip()
WaitEvent
Forever
EndDoubleBuffer()
Video Preview Here: https://odysee.com/@oceancrafts:e/Holly ... SL9Mdxf65i