-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.agc
110 lines (89 loc) · 3.11 KB
/
main.agc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*------------------------------------------------------------------------------*\
Galaga - Arcade game remake
Created by Stefan Wessels.
Copyright (c) 2017 Wessels Consulting Ltd. All rights reserved.
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely.
\*------------------------------------------------------------------------------*/
//------------------------------------------------------------------------------
// show all errors
SetErrorMode(2)
//------------------------------------------------------------------------------
#insert "globals.agc"
#insert "setup.agc"
#insert "input.agc"
#insert "startup.agc"
#insert "background.agc"
#insert "attract.agc"
#insert "spawn.agc"
#insert "play.agc"
#insert "misc.agc"
/*-----------------------------------------------------------------------------*\
* * * * G A L A G A -- M A I N * * * *
\*-----------------------------------------------------------------------------*/
Setup()
StartupSequence()
SetupJoystick()
MakeStars(cNumStars)
MainLoop()
//------------------------------------------------------------------------------
function MainLoop()
// Show 1UP, HIGH SCORE and initial high score
SetTextRangeVisible(TEXT_1UP, TEXT_20000, 1)
ResetTimer()
do
//Print(ScreenFPS())
gDT# = Timer()
ProcessStars()
ProcessInput()
// Handle the hardware coin drop here
if gCoinDropped
PlaySound(gSounds[SOUND_COIN])
AddCredit()
if gState = cStateAttractLoop then SetSubState(cASHaveCredit)
if gVirtualStick
if gNumCredits < 2
SetVirtualButtonVisible(VB_1P_START, 1)
SetVirtualButtonVisible(VB_2P_START, 0)
else
SetVirtualButtonVisible(VB_2P_START, 1)
endif
endif
endif
// game state machine
select gState
// Anything to do with the front end (but not the back end - post play before
// game over
case cStateAttractLoop:
// Makew sure there are always gCoinDroppeds to play
DoAttractSequence()
if (gStart = 1 and gNumCredits) or (gStart = 2 and gNumCredits > 1)
gNumPlayers = gStart
UseCredits()
SetTextRangeVisible(TEXT_GALAGA, TEXT_END_GAME_TEXT, 0)
SetSpriteRangeVisible(0, gSprites.length, 0)
SetStates(cStatePlayGame, cPSInitGame)
endif
endcase
// Playing the game, and post game flow
case cStatePlayGame:
if not PlayGame()
SetStates(cStateAttractLoop, cASTitle)
SetSpriteRangeVisible(0, gSpriteOffsets[IMAGE_RED_BULLET], 0)
if gVirtualStick
SetVirtualButtonVisible(VB_CoinDrop, 1)
if gNumCredits > 0 then SetVirtualButtonVisible(VB_1P_START, 1)
if gNumCredits > 1 then SetVirtualButtonVisible(VB_2P_START, 1)
SetVirtualJoystickVisible(VJ_Stick, 0)
SetVirtualButtonVisible(VB_Fire, 0)
endif
endif
endcase
endselect
// Set up to time the frame
ResetTimer()
Sync()
loop
endfunction