-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.html
183 lines (167 loc) · 7.36 KB
/
game.html
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/phaser/3.55.2/phaser.min.js"></script>
<style>
canvas {
display: block;
margin: 0 auto;
width: 800px;
background-size: cover;
background-position: center;
}
</style>
</head>
<body>
<script>
var config = {
type: Phaser.AUTO,
width: 800,
height: 600,
scene: {
preload: preload,
create: create
}
};
var game = new Phaser.Game(config);
function preload() {
this.load.image('background', './game/map.jpg');
this.load.image('shadowedRegions', './game/psr.jpg');
this.load.image('time', './game/time.png');
this.load.image('grid', './game/grid.jpg');
this.load.audio('backgroundMusic', './game/sound.mp3');
}
var fundingText;
var Metal;
var Glass;
var Time;
var mapDisplay = 'normal';
function create() {
// initializes the map
var background = this.add.image(435, 225, 'background').setDisplaySize(600, 450);
var shadowedRegions = this.add.image(435, 225, 'shadowedRegions').setDisplaySize(600, 450);
var grid = this.add.image(435, 225, 'grid').setDisplaySize(600, 450);
shadowedRegions.visible = false;
grid.visible = false;
music = this.sound.add('backgroundMusic', { loop: true });
music.play();
// initalizes resource list
var fundingValue = 1000;
fundingText = this.add.text(8, 16, "Funding: " + fundingValue + " XMR", { fontSize: '12px', fill: '#fff' });
metalText = this.add.text(8, 40, "Metal: 0", { fontSize: '12px', fill: '#fff' });
glassText = this.add.text(8, 64, "Glass: 0", { fontSize: '12px', fill: '#fff' });
// Initializes timing
timingText = this.add.text(61, 395, "Q1 2023", { fontSize: '16px', fill: '#fff' });
var quarter = 1;
var year = 2023;
var timingButton = this.add.image(32, 400, 'time').setDisplaySize(40, 40);
timingButton.setInteractive();
// Initialize active missions
missiontext = this.add.text(3, 100, "Active missions:", { fontSize: '14px', fill: '#fff' });
// Initialize available missions
missiontext = this.add.text(3, 200, "Available missions:", { fontSize: '13px', fill: '#fff' });
// Initialize Inventory menu
inventoryText = this.add.text(10, 430, "Inventory:", { fontSize: '13px', fill: '#fff' });
launchText = this.add.text(10, 480, "LAUNCH PAYLOAD REMAINING: 30, 000 ft^2", { fontSize: '13px', fill: '#fff' });
launchText = this.add.text(60, 490, "RAZZOR", { fontSize: '13px', fill: '#fff' });
// Initializes launch button
launchButton = this.add.rectangle(720, 580, 100, 25, 0x696969, 1);
launchButton.setInteractive();
var launchButtonText = this.add.text(650, 550, 'Launch starship', { align: 'center' });
launchButtonText.setOrigin(0.5);
launchButton.on('pointerdown', function () {
// do something when the button is clicked, such as launching the starship
launchButton.setFillStyle(0xebc634);
fundingValue -= 100;
fundingText.setText("Funding: " + fundingValue + " XMR");
});
// add CSS styling to the launch button
launchButton.setStrokeStyle(2, 0xff0000);
launchButtonText.setShadow(2, 2, "#333333", 2, false, true);
// add hover effect to the button
launchButton.on('pointerover', function () {
launchButton.setFillStyle(0x9e9e9e);
});
launchButton.on('pointerout', function () {
launchButton.setFillStyle(0x696969);
});
// map menu
standardMapButton = this.add.rectangle(767, 35, 60, 60, 0x696969, 1);
psrMapButton = this.add.rectangle(767, 100, 60, 60, 0x696969, 1);
gridMapButton = this.add.rectangle(767, 165, 60, 60, 0x696969, 1);
standardMapButton.setInteractive();
psrMapButton.setInteractive();
gridMapButton.setInteractive();
var standardButtonText = this.add.text(765, 35, 'Std', { align: 'center' });
var psrButtonText = this.add.text(765, 100, 'PSR', { align: 'center' });
var gridButtonText = this.add.text(765, 165, 'Grid', { align: 'center' });
standardButtonText.setOrigin(0.5);
psrButtonText.setOrigin(0.5);
gridButtonText.setOrigin(0.5);
// add CSS styling to the button
standardMapButton.setStrokeStyle(2, 0xebdb34);
standardButtonText.setShadow(2, 2, "#333333", 2, false, true);
psrMapButton.setStrokeStyle(2, 0xebdb34);
psrButtonText.setShadow(2, 2, "#333333", 2, false, true);
gridMapButton.setStrokeStyle(2, 0xebdb34);
gridButtonText.setShadow(2, 2, "#333333", 2, false, true);
// add hover effect to the buttons
standardMapButton.on('pointerover', function () {
standardMapButton.setFillStyle(0x9e9e9e);
});
standardMapButton.on('pointerout', function () {
standardMapButton.setFillStyle(0x696969);
});
psrMapButton.on('pointerover', function () {
psrMapButton.setFillStyle(0x9e9e9e);
});
psrMapButton.on('pointerout', function () {
psrMapButton.setFillStyle(0x696969);
});
gridMapButton.on('pointerover', function () {
gridMapButton.setFillStyle(0x9e9e9e);
});
gridMapButton.on('pointerout', function () {
gridMapButton.setFillStyle(0x696969);
});
standardMapButton.on('pointerdown', function () {
// do something when the button is clicked
mapDisplay = 'normal';
background.visible = true;
shadowedRegions.visible = false;
grid.visible = false;
});
psrMapButton.on('pointerdown', function () {
// do something when the button is clicked
mapDisplay = 'psr';
shadowedRegions.visible = true;
background.visible = false;
grid.visible = false;
});
gridMapButton.on('pointerdown', function () {
// do something when the button is clicked
mapDisplay = 'grid';
shadowedRegions.visible = false;
background.visible = false;
grid.visible = true;
});
// button to advance time in game. Price of stuff changes, long term missions make progress, random events can occur, AI art
timingButton.on('pointerdown', function () {
if(quarter == 4){
quarter = 1;
year ++;
timingText.setText("Q1 " + year);
}
else{
quarter ++;
timingText.setText("Q" + quarter + " " + year);
}
// TODO: add dyanimc semirandom events which can drive gameplay outcomes
});
// TODO: add missions
// TODO: build launch feature. You can add avaialbe technolgies to your launch, as long as they all fit.
// TODO: add in grid organized system.
}
</script>
</body>
</html>