Removed vsstudio project
works on mac other minor changes
This commit is contained in:
@@ -129,10 +129,10 @@ int CheckEnemyHit(int n1, int n2) {
|
||||
}
|
||||
|
||||
void Enemies::ProcessMessage(const char* msg) {
|
||||
if (msg == "CheckEnemyHit") {
|
||||
if (strcmp(msg, "CheckEnemyHit") == 0) {
|
||||
int* params = GetMessageParams();
|
||||
SetMessageReturn(CheckEnemyHit(params[0], params[1]));
|
||||
} else if (msg == "ResetEnemies") {
|
||||
} else if (strcmp(msg, "ResetEnemies") == 0) {
|
||||
betweenWaves = 420; ResetEnemies();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ void GenerateExplosion(int x, int y) {
|
||||
}
|
||||
|
||||
void Explosions::ProcessMessage(const char* msg) {
|
||||
if (msg == "GenerateExplosion") {
|
||||
if (message_eq("GenerateExplosion")) {
|
||||
int* params = GetMessageParams();
|
||||
GenerateExplosion(params[0], params[1]);
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ void CreateNewLaser(float x1, float y1, float x2, float y2, unsigned char r, uns
|
||||
}
|
||||
|
||||
void Lasers::ProcessMessage(const char* msg) {
|
||||
if (msg == "CreateNewLaser") {
|
||||
if (message_eq("CreateNewLaser")) {
|
||||
int* params = GetMessageParams();
|
||||
if (params[4] == 0) {
|
||||
CreateNewLaser(params[0], params[1], params[2], params[3], 255, 0, 0);
|
||||
|
||||
6
Makefile
Executable file
6
Makefile
Executable file
@@ -0,0 +1,6 @@
|
||||
game :
|
||||
g++ *.cpp -std=c++11 -lSDL2 -o mathwars
|
||||
|
||||
run : game
|
||||
./mathwars
|
||||
|
||||
@@ -15,7 +15,8 @@ Score::Score() {
|
||||
|
||||
void Score::Update() {
|
||||
char strScore[10];
|
||||
itoa(score, strScore, 10);
|
||||
sprintf(strScore, "%d", score);
|
||||
//itoa(score, strScore, 10);
|
||||
Print(220, 4, strScore, 255, 255, 0);
|
||||
if (lives > 0) Draw(5, 5, 10, 85, 18, 18);
|
||||
if (lives > 1) Draw(25, 5, 10, 85, 18, 18);
|
||||
@@ -23,10 +24,10 @@ void Score::Update() {
|
||||
}
|
||||
|
||||
void Score::ProcessMessage(const char* msg) {
|
||||
if (msg == "IncreaseScore") {
|
||||
if (message_eq("IncreaseScore")) {
|
||||
int* params = GetMessageParams();
|
||||
score += params[0];
|
||||
} else if (msg == "DecreaseLives") {
|
||||
} else if (message_eq("DecreaseLives")) {
|
||||
lives--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ void StarField::Update() {
|
||||
}
|
||||
|
||||
void StarField::ProcessMessage(const char* msg) {
|
||||
if (msg == "SetStarFieldVelocity") {
|
||||
if (message_eq("SetStarFieldVelocity")) {
|
||||
int* params = GetMessageParams();
|
||||
speed = params[0] * 0.01f;
|
||||
}
|
||||
|
||||
@@ -72,10 +72,11 @@ void SetNumbers(int p1, int p2) {
|
||||
}
|
||||
|
||||
void Xwing::ProcessMessage(const char* msg) {
|
||||
if (msg == "HeroHit") {
|
||||
if (message_eq("HeroHit")) {
|
||||
//if (msg == "HeroHit") {
|
||||
int* params = GetMessageParams();
|
||||
HeroHit(params[0], params[1]);
|
||||
} else if (msg == "SetNumbers") {
|
||||
} else if (message_eq("SetNumbers")) {
|
||||
int* params = GetMessageParams();
|
||||
SetNumbers(params[0], params[1]);
|
||||
}
|
||||
|
||||
1
api.cpp
1
api.cpp
@@ -1,6 +1,7 @@
|
||||
#include "api.h"
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include "stb_image.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
4
api.h
4
api.h
@@ -1,9 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL2/SDL.h>
|
||||
#include "System.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#define message_eq(m) strncmp(msg, m, 20)
|
||||
|
||||
enum BlendMode { BlendNone, BlendBlend, BlendAdd, BlendMod };
|
||||
|
||||
struct Point {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include "api.h"
|
||||
|
||||
@@ -14,8 +13,15 @@
|
||||
int digit = -1;
|
||||
|
||||
void keyHandler(SDL_Scancode key) {
|
||||
int num = 0;
|
||||
if (key >= 89 && key <= 98) {
|
||||
int num = key == 98 ? 0 : key - 88;
|
||||
num = key == 98 ? 0 : key - 88;
|
||||
} else if (key >= 30 && key <= 39) {
|
||||
num = key == 39 ? 0 : key - 29;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (digit == -1) {
|
||||
digit = num;
|
||||
SendMessage("CheckEnemyHit", 0, num);
|
||||
@@ -32,7 +38,6 @@ void keyHandler(SDL_Scancode key) {
|
||||
digit = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void menuKeyHandler(SDL_Scancode key) {
|
||||
Reset();
|
||||
|
||||
1
main.cpp
1
main.cpp
@@ -1,4 +1,5 @@
|
||||
#include "api.h"
|
||||
#include <unistd.h>
|
||||
|
||||
#include "keyHandlers.h"
|
||||
#include "StarField.h"
|
||||
|
||||
22
mathwars.sln
22
mathwars.sln
@@ -1,22 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.31101.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mathwars", "mathwars.vcxproj", "{5CCE4316-2638-47DA-9C0B-3075E1120FD1}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{5CCE4316-2638-47DA-9C0B-3075E1120FD1}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{5CCE4316-2638-47DA-9C0B-3075E1120FD1}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{5CCE4316-2638-47DA-9C0B-3075E1120FD1}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{5CCE4316-2638-47DA-9C0B-3075E1120FD1}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
110
mathwars.vcxproj
110
mathwars.vcxproj
@@ -1,110 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{5CCE4316-2638-47DA-9C0B-3075E1120FD1}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>mathwars</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>C:\dev\lib\sdl2\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>C:\dev\lib\sdl2\lib\x86;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>SDL2.lib;SDL2main.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="api.cpp" />
|
||||
<ClCompile Include="Enemies.cpp" />
|
||||
<ClCompile Include="Explosions.cpp" />
|
||||
<ClCompile Include="keyHandlers.cpp" />
|
||||
<ClCompile Include="Lasers.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="Menu.cpp" />
|
||||
<ClCompile Include="Score.cpp" />
|
||||
<ClCompile Include="StarField.cpp" />
|
||||
<ClCompile Include="Xwing.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="api.h" />
|
||||
<ClInclude Include="Enemies.h" />
|
||||
<ClInclude Include="Explosions.h" />
|
||||
<ClInclude Include="keyHandlers.h" />
|
||||
<ClInclude Include="Lasers.h" />
|
||||
<ClInclude Include="Menu.h" />
|
||||
<ClInclude Include="Score.h" />
|
||||
<ClInclude Include="StarField.h" />
|
||||
<ClInclude Include="stb_image.h" />
|
||||
<ClInclude Include="System.h" />
|
||||
<ClInclude Include="Xwing.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -1,84 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="api.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="StarField.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Explosions.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Lasers.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Enemies.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Xwing.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Score.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Menu.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="keyHandlers.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="stb_image.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="System.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="api.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="StarField.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Explosions.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Lasers.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Enemies.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Xwing.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Score.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Menu.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="keyHandlers.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user