-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
executable file
·430 lines (370 loc) · 17.9 KB
/
main.go
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
// main.go
package main
import (
"fmt"
"math/rand"
"os"
"time"
"golang.org/x/image/colornames"
"github.com/veandco/go-sdl2/mix"
"github.com/veandco/go-sdl2/sdl"
)
//==============SETTINGS==============
const (
//==============WINDOW SETTINGS==============
TITLE string = "Tank game"
SCREEN_WIDTH int32 = 500
SCREEN_HEIGHT int32 = 500
VSYNC bool = true
SMOOTH_TEXTURES bool = true
)
const (
//==============ANTI-ALIASING TYPES==============
NEAREST string = "0"
LINEAR string = "1"
ANISOTROPIC string = "2"
)
const (
//==============TEXTURE PATHS==============
PLAYER_TANK_TEXTURE_PATH string = "resources/player-tank.png" // Make the textures, to be in same rotation angle
ENEMY_TANK_TEXTURE_PATH string = "resources/enemy-tank.png" // Make the textures, to be in same rotation angle
BULLET_TEXTURE_PATH string = "resources/bullet_6.png" // Make the textures, to be in same rotation angle
//==============SOUND EFFECTS PATHS==============
SHOOT_SOUND_PATH string = "resources/flak_gun_sound.ogg"
EXPLOSION_SOUND_PATH string = "resources/bombexplosion.ogg"
)
//==============EXPLOSION ANIMATION==============
const (
EXPLOSION_ANIMATION_TEXTURE_PATH string = "resources/explosion_animation.png"
// for now, these are hard coded(change these, if you change the texture image)
CELL_WIDTH int32 = 128
CELL_HEIGHT int32 = 128
NUMBER_OF_CELLS_LENGTH_WISE int = 8
NUMBER_OF_CELLS_BREADTH_WISE int = 8
)
var EXPLOSION_ANIMATION_COORDS [NUMBER_OF_CELLS_LENGTH_WISE * NUMBER_OF_CELLS_BREADTH_WISE]sdl.Point = [NUMBER_OF_CELLS_LENGTH_WISE * NUMBER_OF_CELLS_BREADTH_WISE]sdl.Point{
sdl.Point{CELL_WIDTH * 0, CELL_HEIGHT * 0}, sdl.Point{CELL_WIDTH * 1, CELL_HEIGHT * 0}, sdl.Point{CELL_WIDTH * 2, CELL_HEIGHT * 0}, sdl.Point{CELL_WIDTH * 3, CELL_HEIGHT * 0}, sdl.Point{CELL_WIDTH * 4, CELL_HEIGHT * 0}, sdl.Point{CELL_WIDTH * 5, CELL_HEIGHT * 0}, sdl.Point{CELL_WIDTH * 6, CELL_HEIGHT * 0}, sdl.Point{CELL_WIDTH * 7, CELL_HEIGHT * 0},
sdl.Point{CELL_WIDTH * 0, CELL_HEIGHT * 1}, sdl.Point{CELL_WIDTH * 1, CELL_HEIGHT * 1}, sdl.Point{CELL_WIDTH * 2, CELL_HEIGHT * 1}, sdl.Point{CELL_WIDTH * 3, CELL_HEIGHT * 1}, sdl.Point{CELL_WIDTH * 4, CELL_HEIGHT * 1}, sdl.Point{CELL_WIDTH * 5, CELL_HEIGHT * 1}, sdl.Point{CELL_WIDTH * 6, CELL_HEIGHT * 1}, sdl.Point{CELL_WIDTH * 7, CELL_HEIGHT * 1},
sdl.Point{CELL_WIDTH * 0, CELL_HEIGHT * 2}, sdl.Point{CELL_WIDTH * 1, CELL_HEIGHT * 2}, sdl.Point{CELL_WIDTH * 2, CELL_HEIGHT * 2}, sdl.Point{CELL_WIDTH * 3, CELL_HEIGHT * 2}, sdl.Point{CELL_WIDTH * 4, CELL_HEIGHT * 2}, sdl.Point{CELL_WIDTH * 5, CELL_HEIGHT * 2}, sdl.Point{CELL_WIDTH * 6, CELL_HEIGHT * 2}, sdl.Point{CELL_WIDTH * 7, CELL_HEIGHT * 2},
sdl.Point{CELL_WIDTH * 0, CELL_HEIGHT * 3}, sdl.Point{CELL_WIDTH * 1, CELL_HEIGHT * 3}, sdl.Point{CELL_WIDTH * 2, CELL_HEIGHT * 3}, sdl.Point{CELL_WIDTH * 3, CELL_HEIGHT * 3}, sdl.Point{CELL_WIDTH * 4, CELL_HEIGHT * 3}, sdl.Point{CELL_WIDTH * 5, CELL_HEIGHT * 3}, sdl.Point{CELL_WIDTH * 6, CELL_HEIGHT * 3}, sdl.Point{CELL_WIDTH * 7, CELL_HEIGHT * 3},
sdl.Point{CELL_WIDTH * 0, CELL_HEIGHT * 4}, sdl.Point{CELL_WIDTH * 1, CELL_HEIGHT * 4}, sdl.Point{CELL_WIDTH * 2, CELL_HEIGHT * 4}, sdl.Point{CELL_WIDTH * 3, CELL_HEIGHT * 4}, sdl.Point{CELL_WIDTH * 4, CELL_HEIGHT * 4}, sdl.Point{CELL_WIDTH * 5, CELL_HEIGHT * 4}, sdl.Point{CELL_WIDTH * 6, CELL_HEIGHT * 4}, sdl.Point{CELL_WIDTH * 7, CELL_HEIGHT * 4},
sdl.Point{CELL_WIDTH * 0, CELL_HEIGHT * 5}, sdl.Point{CELL_WIDTH * 1, CELL_HEIGHT * 5}, sdl.Point{CELL_WIDTH * 2, CELL_HEIGHT * 5}, sdl.Point{CELL_WIDTH * 3, CELL_HEIGHT * 5}, sdl.Point{CELL_WIDTH * 4, CELL_HEIGHT * 5}, sdl.Point{CELL_WIDTH * 5, CELL_HEIGHT * 5}, sdl.Point{CELL_WIDTH * 6, CELL_HEIGHT * 5}, sdl.Point{CELL_WIDTH * 7, CELL_HEIGHT * 5},
sdl.Point{CELL_WIDTH * 0, CELL_HEIGHT * 6}, sdl.Point{CELL_WIDTH * 1, CELL_HEIGHT * 6}, sdl.Point{CELL_WIDTH * 2, CELL_HEIGHT * 6}, sdl.Point{CELL_WIDTH * 3, CELL_HEIGHT * 6}, sdl.Point{CELL_WIDTH * 4, CELL_HEIGHT * 6}, sdl.Point{CELL_WIDTH * 5, CELL_HEIGHT * 6}, sdl.Point{CELL_WIDTH * 6, CELL_HEIGHT * 6}, sdl.Point{CELL_WIDTH * 7, CELL_HEIGHT * 6},
sdl.Point{CELL_WIDTH * 0, CELL_HEIGHT * 7}, sdl.Point{CELL_WIDTH * 1, CELL_HEIGHT * 7}, sdl.Point{CELL_WIDTH * 2, CELL_HEIGHT * 7}, sdl.Point{CELL_WIDTH * 3, CELL_HEIGHT * 7}, sdl.Point{CELL_WIDTH * 4, CELL_HEIGHT * 7}, sdl.Point{CELL_WIDTH * 5, CELL_HEIGHT * 7}, sdl.Point{CELL_WIDTH * 6, CELL_HEIGHT * 7}, sdl.Point{CELL_WIDTH * 7, CELL_HEIGHT * 7},
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
const (
//==============GAMEPLAY==============
BULLET_VELOCITY float32 = 500
TANK_ROTATION_ANGLE float32 = 500 // TODO : Why so low rotation on setting this to 5?(maybe due to delta calculation)
PLAYER_TANK_VELOCITY float32 = 300
EXPLOSION_ANIMATION_LIFE_SPAN float32 = 0.5 // seconds
//==============SPECIAL FLAGS==============
CRAZY_TANKS bool = false // A special flag, toggle it, and enjoy!
)
//==============LEVEL SETTINGS==============
const (
LEVEL_0_MAX_NUM_OF_ENEMY_TANKS int = 10
LEVEL_0_ENEMY_SPAWN_OFF_TIME float32 = 3.0 // seconds
LEVEL_0_ENEMY_TANK_VELOCITY float32 = 310
LEVEL_0_ENEMY_TANK_MIN_NO_UPDATES_TIME float32 = 1.0 // seconds
LEVEL_0_ENEMY_TANK_MAX_NO_UPDATES_TIME float32 = 3.0 // seconds
)
/*
TODO : Use batch rendering, it is necessary for specifically a large number of bullets
*/
func run() int {
//==============VARS==============
r := rand.New(rand.NewSource(time.Now().UnixNano())) // TODO : What to do after 2262(UnixNano)???
/* TODO : Most probably depricated
//==============SDL INIT==============
err := sdl.Init(sdl.INIT_EVERYTHING)
if err != nil {
HandleError("Failed to initialize sdl:", err)
os.Exit(ERROR_FAILED_TO_INIT_SDL)
}*/
//==============CREATE WINDOW==============
window, err := sdl.CreateWindow(TITLE, sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED,
SCREEN_WIDTH, SCREEN_HEIGHT, sdl.WINDOW_SHOWN)
if err != nil {
HandleError("Failed to create window: ", err)
return ERROR_FAILED_TO_CREATE_WINDOW
}
defer window.Destroy()
//==============CREATE RENDERER==============
var renderer *sdl.Renderer
if VSYNC {
renderer, err = sdl.CreateRenderer(window, -1, sdl.RENDERER_ACCELERATED|sdl.RENDERER_PRESENTVSYNC)
} else {
renderer, err = sdl.CreateRenderer(window, -1, sdl.RENDERER_ACCELERATED)
}
if err != nil {
HandleError("Failed to create renderer: ", err)
return ERROR_FAILED_TO_CREATE_RENDERER
}
defer renderer.Destroy()
// sdl.SetHint(sdl.HINT_DEFAULT)
if SMOOTH_TEXTURES {
sdl.SetHint(sdl.HINT_RENDER_SCALE_QUALITY, LINEAR)
}
//==============SOUND EFFECTS==============
if err := mix.OpenAudio(mix.DEFAULT_FREQUENCY, mix.DEFAULT_FORMAT, mix.DEFAULT_CHANNELS, mix.DEFAULT_CHUNKSIZE); err != nil {
HandleError("Cannot play audio, you may play without it: ", err)
}
defer mix.CloseAudio()
shootSoundEffect := GetSoundEffect(SHOOT_SOUND_PATH)
defer shootSoundEffect.Free()
explosionSoundEffect := GetSoundEffect(EXPLOSION_SOUND_PATH)
defer explosionSoundEffect.Free()
//==============PLAYER TANK==============
playerTankImage, playerTankTexture, errorCode := GetTexture(PLAYER_TANK_TEXTURE_PATH, renderer)
if errorCode != 0 {
return errorCode
}
defer playerTankImage.Free()
defer playerTankTexture.Destroy()
playerTank := &PlayerTank{
tankTexture: playerTankTexture,
rotationAngle: 0.0,
boundingBox: sdl.FRect{
X: (float32(SCREEN_WIDTH) / 2.0) - (float32(playerTankImage.W) / 2.0), // positioning exactly at the centre of the screen
Y: (float32(SCREEN_HEIGHT) / 2.0) - (float32(playerTankImage.H) / 2.0), // positioning exactly at the centre of the screen
W: float32(playerTankImage.W),
H: float32(playerTankImage.H),
},
}
var playerTankBullets []Bullet
//==============CALLBACKS==============
callbacks := map[sdl.Scancode]func(delta float32) *PlayerTank{
sdl.SCANCODE_LEFT: playerTank.RotateAntiClockWise,
sdl.SCANCODE_RIGHT: playerTank.RotateClockWise,
sdl.SCANCODE_W: playerTank.MoveUp,
sdl.SCANCODE_A: playerTank.MoveLeft,
sdl.SCANCODE_S: playerTank.MoveDown,
sdl.SCANCODE_D: playerTank.MoveRight,
}
//==============ENEMY TANKS==============
enemyTankImage, enemyTankTexture, errorCode := GetTexture(ENEMY_TANK_TEXTURE_PATH, renderer)
if errorCode != 0 {
return errorCode
}
defer enemyTankImage.Free()
defer enemyTankTexture.Destroy()
x := 2 + r.Intn(LEVEL_0_MAX_NUM_OF_ENEMY_TANKS/2) // Initially random num.of tanks will be alive(halving it so that the generated random no. is not too much), let us make at least 2 tanks alive at first
enemyTanks := make([]EnemyTank, x)
i := 0
for i = 0; i < x; i++ { // first x no.of tanks will be alive
if CRAZY_TANKS {
enemyTanks[i] = NewEnemyTank(enemyTankTexture, enemyTankImage.W, enemyTankImage.H, r.Float32()*360.0, GetRandomFloat32(0.0, 0.5, r))
} else {
enemyTanks[i] = NewEnemyTank(enemyTankTexture, enemyTankImage.W, enemyTankImage.H, r.Float32()*360.0, GetRandomFloat32(LEVEL_0_ENEMY_TANK_MIN_NO_UPDATES_TIME, LEVEL_0_ENEMY_TANK_MAX_NO_UPDATES_TIME, r))
}
}
numOfEnemyTanksSpawned := x
SetPositionOfEnemyTanks(enemyTanks, playerTank.boundingBox, r)
var enemyTankBullets []Bullet
last := time.Now() // for calculating dt(delta)
var enemyTankSpawnTimer float32 = 0.0
fpsCounter := 0
var fpsTimer float32 = 0.0
//==============BULLET==============
bulletImage, bulletTexture, errorCode := GetTexture(BULLET_TEXTURE_PATH, renderer)
if errorCode != 0 {
return errorCode
}
defer bulletImage.Free()
defer bulletTexture.Destroy()
//==============EXPLOSION ANIMATION==============
var explosions []Explosion
explosionImage, explosionTexture, errorCode := GetTexture(EXPLOSION_ANIMATION_TEXTURE_PATH, renderer)
if errorCode != 0 {
return errorCode
}
defer explosionImage.Free()
defer explosionTexture.Destroy()
//==============MAIN LOOP==============
keyboardState := sdl.GetKeyboardState() // for handling keyboard events
running := true // Main loop flag
playerShootedInLastFrame := false // just a flag, to manage player tank shoot events(it ensures that the player tank will not shoot continuously, on pressing down 'space')
for running {
//==============CALCULATING dt(DELTA)==============
dt := float32(time.Since(last).Seconds())
last = time.Now()
//==============PRINTING FPS==============
fpsTimer += dt
if fpsTimer >= 1.0 {
fmt.Println("Current FPS: ", fpsCounter)
fpsTimer = 0.0
fpsCounter = 0
}
//==============CHECKING WHETHER PLAYER HAS WON==============
if (len(enemyTanks) == 0) /*if all the tanks has been destroyed by the player, and*/ &&
(numOfEnemyTanksSpawned == LEVEL_0_MAX_NUM_OF_ENEMY_TANKS) /*if all the tanks has been spawned*/ {
// TODO: Render text, instead of printing inside the console
fmt.Println("==============PLAYER WON==============")
sdl.Delay(1000)
break
}
//==============SPAWNING NEW ENEMY TANKS==============
enemyTankSpawnTimer += dt
if (enemyTankSpawnTimer >= LEVEL_0_ENEMY_SPAWN_OFF_TIME) && (numOfEnemyTanksSpawned < LEVEL_0_MAX_NUM_OF_ENEMY_TANKS) {
if CRAZY_TANKS {
enemyTanks = append(enemyTanks, NewEnemyTank(enemyTankTexture, enemyTankImage.W, enemyTankImage.H, r.Float32()*360.0, GetRandomFloat32(0.0, 0.5, r)))
} else {
enemyTanks = append(enemyTanks, NewEnemyTank(enemyTankTexture, enemyTankImage.W, enemyTankImage.H, r.Float32()*360.0, GetRandomFloat32(LEVEL_0_ENEMY_TANK_MIN_NO_UPDATES_TIME, LEVEL_0_ENEMY_TANK_MAX_NO_UPDATES_TIME, r)))
}
IndexOfLastEnemyTank := len(enemyTanks) - 1
enemyTanks[IndexOfLastEnemyTank].boundingBox = GetPositionOfOneEnemyTank(enemyTanks[IndexOfLastEnemyTank].boundingBox, enemyTanks[:IndexOfLastEnemyTank], playerTank.boundingBox, r)
enemyTankSpawnTimer = 0.0
numOfEnemyTanksSpawned += 1
}
//==============UPDATING ENEMY TANKS==============
var bullet Bullet
var experimentalEnemyTank EnemyTank
for index := range enemyTanks {
//==============UPDATING ANIMATION(ON EVERY FRAME)==============
enemyTanks[index].UpdateAnimation(dt)
//==============UPDATING POSITION AND ROTATION, SHOOTING BULLETS==============
if enemyTanks[index].WillUpdate() { // updating based on an update timer
switch r.Intn(3) {
case 0:
experimentalEnemyTank = enemyTanks[index].MoveInRandomDir(dt, r)
if ValidPosition(experimentalEnemyTank.boundingBox, enemyTanks, playerTank.boundingBox) {
enemyTanks[index].boundingBox = experimentalEnemyTank.boundingBox
}
case 1:
enemyTanks[index].Rotate(r, sdl.FPoint{
X: playerTank.boundingBox.X,
Y: playerTank.boundingBox.Y,
})
case 2:
bullet = enemyTanks[index].Shoot(bulletTexture, bulletImage.W, bulletImage.H)
enemyTankBullets = append(enemyTankBullets, bullet)
PlaySoundEffect(shootSoundEffect)
}
}
}
//==============UPDATING ENEMY TANK BULLETS==============
for index := range enemyTankBullets {
enemyTankBullets[index].Update(dt)
}
//==============OPTIMIZATON(removing the bullets, which are out of the window)==============
// range over slice will not work, as:
// for i, _ := range ...{...}, here the maximum value of i is the length of the slice
// i is initialized with length of the slice, but it doesn't assert new value of that length, when the length of that slice changes
// for i := 0; i < len(...); i++ {...} in this kind of loop the ;len(...); condition is always checked
for i := 0; i < len(playerTankBullets); i++ {
if !IsInsideWindow(playerTankBullets[i].boundingBox) {
playerTankBullets = RemoveElementFromBulletSlice(playerTankBullets, i)
}
}
for i := 0; i < len(enemyTankBullets); i++ {
if !IsInsideWindow(enemyTankBullets[i].boundingBox) {
enemyTankBullets = RemoveElementFromBulletSlice(enemyTankBullets, i)
}
}
//==============EVENT HANDLING==============
for event := sdl.PollEvent(); event != nil; event = sdl.PollEvent() {
if event.GetType() == sdl.QUIT {
running = false
}
switch t := event.(type) {
case *sdl.KeyboardEvent:
if t.Keysym.Sym == sdl.K_SPACE {
if event.GetType() == sdl.KEYDOWN {
if !playerShootedInLastFrame {
playerTankBullets = append(playerTankBullets, playerTank.Shoot(bulletTexture, bulletImage.W, bulletImage.H))
PlaySoundEffect(shootSoundEffect)
playerShootedInLastFrame = true
}
}
if event.GetType() == sdl.KEYUP {
playerShootedInLastFrame = false
}
}
}
}
// sdl.PumpEvents() // not required
if keyboardState[sdl.SCANCODE_ESCAPE] == 1 {
running = false
}
for key, callbackFunc := range callbacks {
if keyboardState[key] == 1 {
intersect := false
experimentalPlayerTank := callbackFunc(dt)
// collision detection with enemy tanks and window
for index := range enemyTanks {
if enemyTanks[index].boundingBox.HasIntersection(&experimentalPlayerTank.boundingBox) {
intersect = true
break
}
}
// if no collision with enemy tanks and window
if !intersect && IsInsideWindow(experimentalPlayerTank.boundingBox) {
// In the callbacks map, if they were declared like: playerTank.moveDown, where playerTank is an actual value, not a pointer to playerTank, then
// the callback functions are 'bound' to that playerTank, with which they were initialized, changing the playerTank will not change the playerTank with
// which they were initialized, so I used playerTank as a pointer.
// TODO : playerTank = experimentalPlayerTank, will not work, why?
playerTank.boundingBox = experimentalPlayerTank.boundingBox
playerTank.rotationAngle = experimentalPlayerTank.rotationAngle
}
}
}
//==============UPDATING PLAYER TANK BULLETS==============
for index := range playerTankBullets {
playerTankBullets[index].Update(dt)
}
//==============DESTROYING ENEMY TANKS(by player tank bullets)==============
for index := range playerTankBullets {
for i := 0; i < len(enemyTanks); i++ {
bulletNosePosition := sdl.FPoint{
playerTankBullets[index].boundingBox.X + playerTankBullets[index].boundingBox.W,
playerTankBullets[index].boundingBox.Y + (playerTankBullets[index].boundingBox.H / 2.0),
}
if bulletNosePosition.InRect(&enemyTanks[i].boundingBox) {
explosions = append(explosions, NewExplosion(enemyTanks[i].boundingBox, explosionTexture))
enemyTanks = RemoveElementFromEnemyTankSlice(enemyTanks, i)
PlaySoundEffect(explosionSoundEffect)
}
}
}
//==============REMOVING DIED EXPLOSION ANIMATIONS==============
for i := 0; i < len(explosions); i++ {
if explosions[i].died {
explosions = RemoveElementFromExplosionSlice(explosions, i)
}
}
//==============UPDATING EXPLOSION ANIMATIONS==============
for index := range explosions {
explosions[index].Update()
}
// TODO : Update first, or draw first?(most probably update first) + update order
// playerTank.Update()
//==============CLEARING THE SCREEN==============
renderer.SetDrawColor(colornames.Bisque.R, colornames.Bisque.G, colornames.Bisque.B, colornames.Bisque.A)
renderer.Clear()
renderer.SetDrawColor(colornames.Red.R, colornames.Red.G, colornames.Red.B, colornames.Red.A)
//==============DRAWING==============
for index := range explosions {
explosions[index].Draw(renderer)
}
DrawTexture(renderer, playerTank.tankTexture, &playerTank.boundingBox, playerTank.rotationAngle)
for index := range playerTankBullets {
DrawTexture(renderer, playerTankBullets[index].bulletTexture, &playerTankBullets[index].boundingBox, playerTankBullets[index].rotationAngle)
}
for index := range enemyTanks {
DrawTexture(renderer, enemyTanks[index].tankTexture, &enemyTanks[index].boundingBox, enemyTanks[index].rotationAngle)
}
for index := range enemyTankBullets {
DrawTexture(renderer, enemyTankBullets[index].bulletTexture, &enemyTankBullets[index].boundingBox, enemyTankBullets[index].rotationAngle)
}
renderer.Present()
//==============UPDATING FPS COUNTER==============
fpsCounter += 1
}
//sdl.Quit()
return 0
}
func main() {
os.Exit(run())
}