Skip to content

Commit 0c330c3

Browse files
committed
Added OpenGL CGE - Thanks KrossX
Also Made CGEGL into CGEGLOOP too!
1 parent a71b31b commit 0c330c3

14 files changed

+4534
-8
lines changed

Core/BattleRoyaleRules.lua

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
-- This is a battle plan file. Here you specify the rules and constraints
2+
-- of the battle. During battle you will not have control of these parameters
3+
-- as they will be set by tournament host
4+
5+
-- DO NOT CHANGE FROM HERE =======================================
6+
7+
-- Enable to stop on robot malfunction and show error message
8+
DebugMode = true
9+
10+
-- Maximum number of robots allowed to enter
11+
MaxRobots = 8
12+
13+
-- Starting Health of robot
14+
MaxRobotHealth = 10
15+
16+
-- Starting energy of robot (in seconds)
17+
MaxRobotEnergy = 30.0
18+
19+
-- Speed of step movement
20+
RobotMoveSpeed = 30.0
21+
22+
-- Duration of step movement
23+
RobotMoveTime = 0.4
24+
25+
-- Speed of turn movement (rad/s)
26+
RobotTurnSpeed = math.pi / 2.0
27+
28+
-- Duration of turn movement
29+
RobotTurnTime = 0.5
30+
31+
-- Maximum Game Time
32+
MaxGameTime = 600.0
33+
34+
-- Gun Cooldown Time
35+
GunCooldown = 0.2
36+
37+
-- Bullet Damage
38+
BulletDamage = 1
39+
40+
-- Bullet Speed
41+
BulletSpeed = 100.0
42+
43+
-- Self Destruct Bullet count
44+
SelfDestructBullets = 10
45+
46+
-- DO NOT CHANGE ABOVE HERE =======================================
47+
48+
49+
-- Robots can be loaded into teams
50+
Teams = {}
51+
Teams["OLC"] = {"javidbot.lua", "javidbot.lua", "javidbot.lua", "brankbot.lua"}
52+
Teams["BadDudes"] = {"nullbot.lua", "nullbot.lua", "nullbot.lua", "nullbot.lua"}
53+
54+

Core/BattleRoyale_Engine.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ void OneLoneCoder_BattleRoyale::Update(float fElapsedTime)
8080
// Update Bullets
8181
for (auto &bullet : vecBullets)
8282
{
83-
bullet.x += bullet.vx * 100.0f * fElapsedTime;
84-
bullet.y += bullet.vy * 100.0f * fElapsedTime;
83+
bullet.x += bullet.vx * BattleRoyale_Parameters::fBulletSpeed * fElapsedTime;
84+
bullet.y += bullet.vy * BattleRoyale_Parameters::fBulletSpeed * fElapsedTime;
8585

8686
// Has bullet left arena?
8787
if (bullet.x<0.0f || bullet.x > 200.0f || bullet.y <0.0f || bullet.y > 200.0f)
@@ -102,7 +102,7 @@ void OneLoneCoder_BattleRoyale::Update(float fElapsedTime)
102102
robot->muxUpdatingSensors.lock();
103103
if (robot->status.health > 0)
104104
{
105-
robot->status.health--;
105+
robot->status.health -= BattleRoyale_Parameters::nBulletDamage;
106106
if (robot->status.health <= 0)
107107
{
108108
robot->status.health = 0;
@@ -131,6 +131,8 @@ void OneLoneCoder_BattleRoyale::Update(float fElapsedTime)
131131
if (nAliveRobots == 1)
132132
bBattleOver = true;
133133

134+
// Count unique teams that still have members that are alive
135+
134136
// Update Robots
135137
for (auto &robot : vecRobots)
136138
{
@@ -282,6 +284,9 @@ float OneLoneCoder_BattleRoyale::GetBattleDuration()
282284

283285
std::string OneLoneCoder_BattleRoyale::AddRobot(std::string sBotFile, int nTeamID)
284286
{
287+
if (vecRobots.size() == BattleRoyale_Parameters::nMaxRobots)
288+
return "TOO MANY ROBOTS";
289+
285290
// Create new robot
286291
cRobot* robot = new cRobot();
287292
robot->status.id = vecRobots.size();
512 Bytes
Binary file not shown.
108 KB
Binary file not shown.
74 KB
Binary file not shown.
512 Bytes
Binary file not shown.

VS2018_BUILD_CGE/BattleRoyale_Console.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,27 @@ SoundCloud: https://www.soundcloud.com/onelonecoder
2828
// This class is just a wrapper that interfaces with the OLC Battle Royale Engine!
2929
// You can create your own interfaces in whatever API you like!
3030

31+
#include <fstream>
32+
#include "../Core/BattleRoyale_Engine.h"
33+
3134
#ifdef CGE_OLC
3235
#include "olcConsoleGameEngineOOP.h"
3336
#endif
3437

35-
#include "../Core/BattleRoyale_Engine.h"
38+
#ifdef CGE_GL
39+
#include "olcConsoleGameEngineGLOOP.h"
40+
#endif
41+
3642

37-
#include <fstream>
3843

3944
#ifdef CGE_OLC
4045
class OneLoneCoder_BattleRoyaleConsole : public olcConsoleGameEngineOOP
4146
#endif
47+
48+
#ifdef CGE_GL
49+
class OneLoneCoder_BattleRoyaleConsole : public olcConsoleGameEngineGLOOP
50+
#endif
51+
4252
{
4353
public:
4454
OneLoneCoder_BattleRoyaleConsole();

VS2018_BUILD_CGE/olcBattleRoyale.sln

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ Global
1111
Debug|x86 = Debug|x86
1212
Release_CGE_Big|x64 = Release_CGE_Big|x64
1313
Release_CGE_Big|x86 = Release_CGE_Big|x86
14+
Release_CGE_GL_Big|x64 = Release_CGE_GL_Big|x64
15+
Release_CGE_GL_Big|x86 = Release_CGE_GL_Big|x86
16+
Release_CGE_Raster|x64 = Release_CGE_Raster|x64
17+
Release_CGE_Raster|x86 = Release_CGE_Raster|x86
1418
Release_CGE_Small|x64 = Release_CGE_Small|x64
1519
Release_CGE_Small|x86 = Release_CGE_Small|x86
1620
Release|x64 = Release|x64
@@ -25,6 +29,14 @@ Global
2529
{57B3E944-D224-4D2A-92F9-674070570C12}.Release_CGE_Big|x64.Build.0 = Release_CGE_Big|x64
2630
{57B3E944-D224-4D2A-92F9-674070570C12}.Release_CGE_Big|x86.ActiveCfg = Release_CGE_Big|Win32
2731
{57B3E944-D224-4D2A-92F9-674070570C12}.Release_CGE_Big|x86.Build.0 = Release_CGE_Big|Win32
32+
{57B3E944-D224-4D2A-92F9-674070570C12}.Release_CGE_GL_Big|x64.ActiveCfg = Release_CGE_GL_Big|x64
33+
{57B3E944-D224-4D2A-92F9-674070570C12}.Release_CGE_GL_Big|x64.Build.0 = Release_CGE_GL_Big|x64
34+
{57B3E944-D224-4D2A-92F9-674070570C12}.Release_CGE_GL_Big|x86.ActiveCfg = Release_CGE_GL_Big|Win32
35+
{57B3E944-D224-4D2A-92F9-674070570C12}.Release_CGE_GL_Big|x86.Build.0 = Release_CGE_GL_Big|Win32
36+
{57B3E944-D224-4D2A-92F9-674070570C12}.Release_CGE_Raster|x64.ActiveCfg = Release_CGE_Raster|x64
37+
{57B3E944-D224-4D2A-92F9-674070570C12}.Release_CGE_Raster|x64.Build.0 = Release_CGE_Raster|x64
38+
{57B3E944-D224-4D2A-92F9-674070570C12}.Release_CGE_Raster|x86.ActiveCfg = Release_CGE_Raster|Win32
39+
{57B3E944-D224-4D2A-92F9-674070570C12}.Release_CGE_Raster|x86.Build.0 = Release_CGE_Raster|Win32
2840
{57B3E944-D224-4D2A-92F9-674070570C12}.Release_CGE_Small|x64.ActiveCfg = Release_CGE_Small|x64
2941
{57B3E944-D224-4D2A-92F9-674070570C12}.Release_CGE_Small|x64.Build.0 = Release_CGE_Small|x64
3042
{57B3E944-D224-4D2A-92F9-674070570C12}.Release_CGE_Small|x86.ActiveCfg = Release_CGE_Small|Win32

0 commit comments

Comments
 (0)