14 Commits

Author SHA1 Message Date
Kayne Ruse
b7a9c009e5 Update README.md 2021-07-20 00:29:11 +10:00
Kayne Ruse
e7c6adf486 Update README.md 2021-07-20 00:24:26 +10:00
Kayne Ruse
762f6ce11d Update README.md 2021-07-20 00:17:09 +10:00
Kayne Ruse
82d918e4d5 Updated build for linux 2015-11-23 23:40:15 +11:00
Kayne Ruse
27996d9511 Added static linking 2013-09-21 16:21:11 +10:00
Kayne Ruse
0da4dda9b0 Added the screenshot 2013-09-06 21:17:01 +10:00
Kayne Ruse
98a70e249c Shoehorned in the button and text interface
This is an attempt to show that I can complete a specified set of
features. The code itself is an absolute mess, and I've always wanted to
refactor this project. For now though, it'll do as far as the portfolio
goes.
2013-09-06 21:06:07 +10:00
Kayne Ruse
a97438a81b Moved main(), imported Button class & resources 2013-09-06 17:04:46 +10:00
Kayne Ruse
dad75c2dfa Moved build process to GCC
* I've replaced the Image class with the newer version
* Removed the sound system to ensure that it compiles & runs
2013-09-06 16:06:50 +10:00
Kayne Ruse
ca8820ba78 Updated some function calls for compatability
Seems to be stable right now.
2013-01-22 03:51:08 +11:00
Kayne Ruse
83e564c80d Updating development files 2013-01-21 03:27:40 +11:00
Kayne Ruse
1a7a7a1f88 Updated Table's compatability 2013-01-21 03:25:08 +11:00
Kayne Ruse
440b13c413 Revamped the card system to use the newer graphics system 2013-01-21 03:14:37 +11:00
Kayne Ruse
c407add405 Switched to a newer grapgics system
Not using Codebase as a submodule, since this project is so small anyway.
2013-01-21 03:06:01 +11:00
41 changed files with 948 additions and 1530 deletions

18
.gitignore vendored
View File

@@ -1,10 +1,24 @@
#Editor generated files #Editor generated files
#*.sln *.sln
#*.vcproj *.vcproj
*.suo *.suo
*.ncb *.ncb
*.user *.user
#Directories #Directories
Release/ Release/
release/
Debug/ Debug/
debug/
Out/
out/
#Project generated files
*.db
*.o
*.a
*.exe
#Shell files
*.bat
*.sh

View File

@@ -1,20 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual C++ Express 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Hearts", "Hearts\Hearts.vcproj", "{A3DAA0E4-CC3F-43F4-BCD1-348A090F753B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A3DAA0E4-CC3F-43F4-BCD1-348A090F753B}.Debug|Win32.ActiveCfg = Debug|Win32
{A3DAA0E4-CC3F-43F4-BCD1-348A090F753B}.Debug|Win32.Build.0 = Debug|Win32
{A3DAA0E4-CC3F-43F4-BCD1-348A090F753B}.Release|Win32.ActiveCfg = Release|Win32
{A3DAA0E4-CC3F-43F4-BCD1-348A090F753B}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -1,330 +0,0 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="Hearts"
ProjectGUID="{A3DAA0E4-CC3F-43F4-BCD1-348A090F753B}"
RootNamespace="Hearts"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="SDL.lib SDLmain.lib SDL_mixer.lib"
LinkIncremental="1"
GenerateDebugInformation="false"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Hearts"
>
<File
RelativePath=".\hearts_engine.cpp"
>
</File>
<File
RelativePath=".\hearts_engine.h"
>
</File>
<File
RelativePath=".\table.cpp"
>
</File>
<File
RelativePath=".\table.h"
>
</File>
<Filter
Name="Card Systems"
>
<File
RelativePath=".\card.cpp"
>
</File>
<File
RelativePath=".\card.h"
>
</File>
<File
RelativePath=".\card_list.cpp"
>
</File>
<File
RelativePath=".\card_list.h"
>
</File>
<File
RelativePath=".\deck.cpp"
>
</File>
<File
RelativePath=".\deck.h"
>
</File>
</Filter>
<Filter
Name="Player Systems"
>
<File
RelativePath=".\player.cpp"
>
</File>
<File
RelativePath=".\player.h"
>
</File>
<File
RelativePath=".\player_ai.cpp"
>
</File>
<File
RelativePath=".\player_ai.h"
>
</File>
<File
RelativePath=".\player_user.cpp"
>
</File>
<File
RelativePath=".\player_user.h"
>
</File>
</Filter>
</Filter>
<Filter
Name="-Notes"
>
<File
RelativePath="..\Notes\Outline.txt"
>
</File>
<File
RelativePath="..\Notes\TODO.txt"
>
</File>
</Filter>
<Filter
Name="KAGE"
>
<File
RelativePath=".\audio_manager.cpp"
>
</File>
<File
RelativePath=".\audio_manager.h"
>
</File>
<File
RelativePath=".\base_engine.cpp"
>
</File>
<File
RelativePath=".\base_engine.h"
>
</File>
<File
RelativePath=".\image.cpp"
>
</File>
<File
RelativePath=".\image.h"
>
</File>
<File
RelativePath=".\image_manager.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\image_manager.h"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCustomBuildTool"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\music.cpp"
>
</File>
<File
RelativePath=".\music.h"
>
</File>
<File
RelativePath=".\named_manager.h"
>
</File>
<File
RelativePath=".\sound.cpp"
>
</File>
<File
RelativePath=".\sound.h"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -1,139 +0,0 @@
/* File Name: audio_manager.cpp
* Author: Kayne Ruse
* Date (dd/mm/yyyy): 21/06/2011
* Copyright: (c) Kayne Ruse 2011, 2012
*
* 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, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* Description:
* The AudioManager class, used to manage sounds and music.
* Part of the KAGE Game Engine.
*/
#include <iostream>
#include "audio_manager.h"
using namespace std;
using namespace KAGE;
//-------------------------
//Public access members
//-------------------------
AudioManager::~AudioManager() {
while(Mix_Init(0))
Mix_Quit();
Mix_CloseAudio();
}
int AudioManager::Init(int flags,int frequency,int format,int channels,int chunkSize) {
if (Mix_OpenAudio(frequency,format,channels,chunkSize) != 0) {
cout << "Error in AudioManager::AudioManager()" << endl;
cout << "Failed to initialise SDL_mixer" << endl;
return -1;
}
int init = Mix_Init(flags);
if (init != flags) {
cout << "Error in AudioManager::AudioManager()" << endl;
cout << "Mix_Init() failed to load all components" << endl;
cout << "Is there a .DLL file missing?" << endl;
cout << "flags: " << flags << "; init: " << init << endl;
return -2;
}
return 0;
}
//-------------------------
//Sounds
//-------------------------
Sound* AudioManager::Add(const char* name,const char* fName) {
if (Exists(name)) {
cout << "Error in AudioManager::Add(name,fName)" << endl;
cout << "A Sound of that name already exists" << endl;
cout << "name: " << name << endl;
return NULL;
}
return NamedManager::Add(name,new Sound(fName));
}
int AudioManager::Play(const char* name,int channel,int loop) {
if (!Exists(name)) {
cout << "Error in AudioManager::Play(name,channel,loop)" << endl;
cout << "No such Sound with that name" << endl;
cout << "name: " << name << endl;
return -2;
}
return Get(name)->Play(channel,loop);
}
int AudioManager::Volume(const char* name,int volume) {
if (!Exists(name)) {
cout << "Error in AudioManager::Volume(name,volume)" << endl;
cout << "No such Sound with that name" << endl;
cout << "name: " << name << endl;
return -2;
}
return Get(name)->Volume(volume);
}
//-------------------------
//Music
//-------------------------
Music* AudioManager::Music() {
return &music;
}
//-------------------------
//Channels
//-------------------------
int AudioManager::ChannelAllocate(int num) {
return Mix_AllocateChannels(num);
}
int AudioManager::ChannelHalt(int channel) {
return Mix_HaltChannel(channel);
}
int AudioManager::ChannelPlaying(int channel) {
return Mix_Playing(channel);
}
void AudioManager::ChannelPause(int channel) {
Mix_Pause(channel);
}
void AudioManager::ChannelResume(int channel) {
Mix_Resume(channel);
}
int AudioManager::ChannelPaused(int channel) {
return Mix_Paused(channel);
}
int AudioManager::ChannelVolume(int volume,int channel) {
return Mix_Volume(channel,volume);
}

View File

@@ -1,70 +0,0 @@
/* File Name: audio_manager.h
* Author: Kayne Ruse
* Date (dd/mm/yyyy): 21/06/2011
* Copyright: (c) Kayne Ruse 2011, 2012
*
* 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, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* Description:
* The AudioManager class, used to manage sounds and music.
* Part of the KAGE Game Engine.
*/
#ifndef KR_KAGE_AUDIOMANAGER_H_
#define KR_KAGE_AUDIOMANAGER_H_
#include "SDL_mixer.h"
#include "named_manager.h"
#include "sound.h"
#include "music.h"
namespace KAGE {
class AudioManager : public KAGE::NamedManager<KAGE::Sound> {
public:
/* Public access members */
~AudioManager();
int Init(int flags,int frequency,int format,int channels,int chunkSize);
/* Sounds */
Sound* Add (const char* name, const char* fName);
int Play (const char* name, int channel = -1, int loop = 0);
int Volume (const char* name, int volume = -1);
/* Music */
KAGE::Music* Music();
/* Channels */
int ChannelAllocate (int num = -1);
int ChannelHalt (int channel = -1);
int ChannelPlaying (int channel = -1);
void ChannelPause (int channel = -1);
void ChannelResume (int channel = -1);
int ChannelPaused (int channel = -1);
int ChannelVolume (int volume = -1,int channel = -1);
private:
/* Private access members */
KAGE::Music music;
};
}
#endif

View File

@@ -186,7 +186,7 @@ void BaseEngine::RedrawScreen() {
} }
void BaseEngine::AdditionalInit() { void BaseEngine::AdditionalInit() {
SDL_WM_SetCaption("KAGE: Kayne's All-purpose Game Engine, By Kayne Ruse",NULL); SDL_WM_SetCaption("Hearts",NULL);
} }
int BaseEngine::TranslateMods(SDL_keysym ks) { int BaseEngine::TranslateMods(SDL_keysym ks) {

View File

@@ -29,7 +29,7 @@
#ifndef KR_KAGE_BASEENGINE_H_ #ifndef KR_KAGE_BASEENGINE_H_
#define KR_KAGE_BASEENGINE_H_ #define KR_KAGE_BASEENGINE_H_
#include "SDL.h" #include "SDL/SDL.h"
namespace KAGE { namespace KAGE {
class BaseEngine { class BaseEngine {
@@ -103,16 +103,4 @@ namespace KAGE {
}; };
} }
#ifndef START
/* Creates SDL_main(). Place this after the derived engine's
* declaration, and pass it the name of the derived engine.
*/
#define START(ENGINE) \
int SDL_main(int,char**) { \
ENGINE app; \
app.Start(true); \
return 0; \
}
#endif
#endif #endif

114
Hearts/button.cpp Normal file
View File

@@ -0,0 +1,114 @@
/* Copyright: (c) Kayne Ruse 2013
*
* 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, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*/
#include "button.hpp"
#include <stdexcept>
Button::Button(std::string bgname, std::string fname, std::string t, Sint16 _x, Sint16 _y) {
LoadSurface(bgname);
LoadFontSurface(fname);
SetText(t);
SetX(x);
SetY(y);
}
Button::Button(SDL_Surface* bg, SDL_Surface* f, std::string t, Sint16 _x, Sint16 _y) {
SetSurface(bg);
SetFontSurface(f);
SetText(t);
SetX(x);
SetY(y);
}
SDL_Surface* Button::LoadSurface(std::string s) {
image.LoadSurface(s);
image.SetClipH(image.GetClipH()/3); //3 phases, vertical storage
SetText(text); //reset textX & textY
return image.GetSurface();
}
SDL_Surface* Button::LoadFontSurface(std::string s) {
font.LoadSurface(s);
SetText(text); //reset textX & textY
return font.GetSurface();
}
SDL_Surface* Button::SetSurface(SDL_Surface* p) {
image.SetSurface(p);
image.SetClipH(image.GetClipH()/3); //3 phases, vertical storage
SetText(text); //reset textX & textY
return image.GetSurface();
}
SDL_Surface* Button::SetFontSurface(SDL_Surface* p) {
font.SetSurface(p);
SetText(text); //reset textX & textY
return font.GetSurface();
}
Button::State Button::MouseMotion(SDL_MouseMotionEvent const& motion) {
return CalcState(motion.x, motion.y, motion.state & SDL_BUTTON_LMASK);
}
Button::State Button::MouseButtonDown(SDL_MouseButtonEvent const& button) {
if (button.button == SDL_BUTTON_LEFT) {
return CalcState(button.x, button.y, true);
}
return state;
}
Button::State Button::MouseButtonUp(SDL_MouseButtonEvent const& button) {
if (button.button == SDL_BUTTON_LEFT) {
return CalcState(button.x, button.y, false);
}
return state;
}
void Button::DrawTo(SDL_Surface* const dest) {
image.DrawTo(dest, x, y);
font.DrawStringTo(text, dest, textX + x, textY + y);
}
std::string Button::SetText(std::string t) {
//one line, cache the position
text = t;
textX = (image.GetClipW() / 2) - (font.GetCharW() * text.size() / 2);
textY = (image.GetClipH() / 2) - (font.GetCharH() / 2);
return text;
}
Button::State Button::CalcState(Sint16 i, Sint16 j, bool leftPressed) {
if (i < x || i > (x + image.GetClipW()) ||
j < y || j > (y + image.GetClipH())
) {
image.SetClipY(0);
return state = State::NORMAL;
}
if (leftPressed) {
image.SetClipY(image.GetClipH()*2);
return state = State::PRESSED;
}
else {
image.SetClipY(image.GetClipH());
return state = State::HOVER;
}
}

91
Hearts/button.hpp Normal file
View File

@@ -0,0 +1,91 @@
/* Copyright: (c) Kayne Ruse 2013
*
* 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, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*/
#ifndef BUTTON_HPP_
#define BUTTON_HPP_
#include "image.hpp"
#include "raster_font.hpp"
#include <string>
//3-phases, no toggle, centred text
class Button {
public:
enum class State {
NORMAL, HOVER, PRESSED
};
Button() = default;
Button(std::string bgname, std::string fontname, std::string t = "", Sint16 x = 0, Sint16 y = 0);
Button(SDL_Surface* background, SDL_Surface* font, std::string t = "", Sint16 x = 0, Sint16 y = 0);
~Button() = default;
//graphics
SDL_Surface* LoadSurface(std::string);
SDL_Surface* LoadFontSurface(std::string);
SDL_Surface* SetSurface(SDL_Surface*);
SDL_Surface* SetFontSurface(SDL_Surface*);
SDL_Surface* GetSurface() const { return image.GetSurface(); }
SDL_Surface* GetFontSurface() const { return font.GetSurface(); }
void FreeSurface() { image.FreeSurface(); }
void FreeFontSurface() { font.FreeSurface(); }
//handle input
State MouseMotion(SDL_MouseMotionEvent const&);
State MouseButtonDown(SDL_MouseButtonEvent const&);
State MouseButtonUp(SDL_MouseButtonEvent const&);
State SetState(State s) { return state = s; }
State GetState() const { return state; }
//yet another draw function
void DrawTo(SDL_Surface* const);
//text string
std::string SetText(std::string);
std::string GetText() const { return text; }
//position
Sint16 SetX(Sint16 i) { return x = i; }
Sint16 SetY(Sint16 i) { return y = i; }
Sint16 GetX() const { return x; }
Sint16 GetY() const { return y; }
//OO Breakers
Image* GetImage() { return &image; }
RasterFont* GetFont() { return &font; }
Sint16 SetTextX(Sint16 i) { return textX = i; }
Sint16 SetTextY(Sint16 i) { return textY = i; }
Sint16 GetTextX() const { return textX; }
Sint16 GetTextY() const { return textY; }
private:
State CalcState(Sint16 x, Sint16 y, bool leftPressed);
Sint16 x = 0, y = 0;
Sint16 textX = 0, textY = 0; //prevent recalc every loop
Image image;
RasterFont font; //TODO: cache this?
State state = State::NORMAL;
std::string text;
};
#endif

View File

@@ -1,7 +1,7 @@
/* File Name: card.cpp /* File Name: card.cpp
* Author: Kayne Ruse * Author: Kayne Ruse
* Date (dd/mm/yyyy): 05/06/2011 * Date (dd/mm/yyyy): 22/01/2013
* Copyright: (c) Kayne Ruse 2011, 2012 * Copyright: (c) Kayne Ruse 2011, 2012, 2013
* *
* This software is provided 'as-is', without any express or implied * This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages * warranty. In no event will the authors be held liable for any damages
@@ -23,50 +23,52 @@
* distribution. * distribution.
* *
* Description: * Description:
* Designed for Project Hearts, 4th try. * A basic playing card. This also has the graphics built in.
*/ */
#include "card.h" #include "card.h"
Card::Card(int _suit, int _rank, SDL_Surface* _faceSurface, SDL_Surface* _backSurface): #include <stdexcept>
Image(_faceSurface),
suit(_suit), //-------------------------
rank(_rank), //Public access members
faceSurface(_faceSurface), //-------------------------
backSurface(_backSurface)
Card::Card(int s, int r, SDL_Surface* faceSurface, SDL_Surface* backSurface):
suit(s),
rank(r)
{ {
SetFace(UP); //images
SetWidth(73); face.SetSurface(faceSurface);
SetHeight(98); back.SetSurface(backSurface);
//set the face's clip (static values based on the card files)
face.SetClipX((rank - 1) * 73);
face.SetClipY((suit - 1) * 98);
face.SetClipW(73);
face.SetClipH(98);
face.SetClipW(73);
face.SetClipH(98);
SetFaceState(UP);
x = 0;
y = 0;
next = NULL; next = NULL;
} }
int Card::Suit() { //-------------------------
//Card game members
//-------------------------
int Card::GetSuit() {
return suit; return suit;
} }
int Card::Rank() { int Card::GetRank() {
return rank; return rank;
} }
int Card::SetFace(int _face) {
face = _face;
if (face == UP) {
SetSurface(faceSurface);
SetClipX((rank - 1) * 73);
SetClipY((suit - 1) * 98);
}
else {
SetSurface(backSurface);
SetClipX(0);
SetClipY(0);
}
return face;
}
int Card::GetFace() {
return face;
}
Card* Card::SetNext(Card* _next) { Card* Card::SetNext(Card* _next) {
return next = _next; return next = _next;
} }
@@ -76,11 +78,10 @@ Card* Card::GetNext() {
} }
bool Card::operator>(Card& card) { bool Card::operator>(Card& card) {
if (Suit() > card.Suit()) if (suit > card.suit)
return true; return true;
if (Suit() == card.Suit() && if (suit == card.suit && rank > card.rank)
Rank() > card.Rank())
return true; return true;
return false; return false;
@@ -89,3 +90,53 @@ bool Card::operator>(Card& card) {
bool Card::operator<(Card& card) { bool Card::operator<(Card& card) {
return card > *this; return card > *this;
} }
//-------------------------
//Graphics members
//-------------------------
int Card::SetFaceState(int face) {
if (face != UP && face != DOWN)
throw(std::invalid_argument("Unknown face value"));
return faceState = face;
}
int Card::GetFaceState() {
return faceState;
}
void Card::SetPos(Sint16 newX, Sint16 newY) {
x = newX;
y = newY;
}
Sint16 Card::SetX(Sint16 newX) {
return x = newX;
}
Sint16 Card::SetY(Sint16 newY) {
return y = newY;
}
Sint16 Card::GetX() {
return x;
}
Sint16 Card::GetY() {
return y;
}
Sint16 Card::GetWidth() {
return face.GetClipW();
}
Sint16 Card::GetHeight() {
return face.GetClipH();
}
void Card::DrawTo(SDL_Surface* const dest) {
if (faceState == UP)
face.DrawTo(dest, x, y);
else if (faceState == DOWN)
back.DrawTo(dest, x, y);
}

View File

@@ -1,7 +1,7 @@
/* File Name: card.h /* File Name: card.h
* Author: Kayne Ruse * Author: Kayne Ruse
* Date (dd/mm/yyyy): 05/06/2011 * Date (dd/mm/yyyy): 22/01/2013
* Copyright: (c) Kayne Ruse 2011, 2012 * Copyright: (c) Kayne Ruse 2011, 2012, 2013
* *
* This software is provided 'as-is', without any express or implied * This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages * warranty. In no event will the authors be held liable for any damages
@@ -23,25 +23,23 @@
* distribution. * distribution.
* *
* Description: * Description:
* Designed for Project Hearts, 4th try. * A basic playing card. This also has the graphics built in.
*/ */
#ifndef KR_CARD_H_ #ifndef KR_CARD_H_
#define KR_CARD_H_ #define KR_CARD_H_
#include "SDL.h"
#include "image.h"
#define ISCARD(CARD,RANK,SUIT) (CARD->Suit() == Card::SUIT && CARD->Rank() == Card::RANK) #include "image.hpp"
class Card : public KAGE::Image { #define ISCARD(CARD,RANK,SUIT) (CARD->GetSuit() == Card::SUIT && CARD->GetRank() == Card::RANK)
class Card {
public: public:
/* Public access members */ /* Public access members */
Card(int suit, int rank, SDL_Surface* faceSurface, SDL_Surface* backSurface); Card(int suit, int rank, SDL_Surface* faceSurface, SDL_Surface* backSurface);
int Suit(); /* Card game memebers */
int Rank(); int GetSuit();
int GetRank();
int SetFace(int face);
int GetFace();
Card* SetNext(Card* next); Card* SetNext(Card* next);
Card* GetNext(); Card* GetNext();
@@ -49,6 +47,22 @@ public:
bool operator>(Card&); bool operator>(Card&);
bool operator<(Card&); bool operator<(Card&);
/* Graphics members */
int SetFaceState(int face);
int GetFaceState();
void SetPos(Sint16 x, Sint16 y);
Sint16 SetX(Sint16);
Sint16 SetY(Sint16);
Sint16 GetX();
Sint16 GetY();
Sint16 GetWidth();
Sint16 GetHeight();
void DrawTo(SDL_Surface* const);
/* Macros */
enum { enum {
UP = 1, DOWN UP = 1, DOWN
}; };
@@ -63,15 +77,17 @@ public:
TEN=9, JACK=10, QUEEN=11, KING=12, ACE=13 TEN=9, JACK=10, QUEEN=11, KING=12, ACE=13
}; };
protected: protected:
/* Protected access members */ /* Card game members */
const int suit; const int suit;
const int rank; const int rank;
int face; //TODO: "facestate"
SDL_Surface* faceSurface; //TODO: Image
SDL_Surface* backSurface;
Card* next; Card* next;
/* Graphics members */
int faceState;
Image face;
Image back;
Sint16 x, y;
}; };
#endif #endif

View File

@@ -1,7 +1,7 @@
/* File Name: card_list.cpp /* File Name: card_list.cpp
* Author: Kayne Ruse * Author: Kayne Ruse
* Date (dd/mm/yyyy): 05/06/2011 * Date (dd/mm/yyyy): 21/01/2013
* Copyright: (c) Kayne Ruse 2011, 2012 * Copyright: (c) Kayne Ruse 2011, 2012, 2013
* *
* This software is provided 'as-is', without any express or implied * This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages * warranty. In no event will the authors be held liable for any damages
@@ -23,12 +23,11 @@
* distribution. * distribution.
* *
* Description: * Description:
* Designed for Project Hearts, 4th try. * A linked list of playing cards.
*/ */
#include <iostream>
#include <time.h>
#include "card_list.h" #include "card_list.h"
using namespace std;
#include <cstdlib>
//------------------------- //-------------------------
//Public access members //Public access members
@@ -144,8 +143,9 @@ Card* CardList::PassSlab(int first, int count) {
//------------------------- //-------------------------
void CardList::Shuffle() { void CardList::Shuffle() {
//TODO: rewrite this to avoid continuous calls to Size()
//New version //New version
srand((unsigned int)time(NULL)); //TODO: Remove this, initiate randomization in the Scene (and shuffle 3 times ;) )
iterator shuffleHead = NULL; iterator shuffleHead = NULL;
iterator prev = NULL; iterator prev = NULL;
@@ -207,7 +207,7 @@ void CardList::SortRank() {
while(it != NULL && Size()) { while(it != NULL && Size()) {
//first card //first card
if (it->Rank() > Read()->Rank()) { if (it->GetRank() > Read()->GetRank()) {
//insert the new card at the start of the list //insert the new card at the start of the list
it = Pass(); it = Pass();
it->SetNext(sortHead); it->SetNext(sortHead);
@@ -215,7 +215,7 @@ void CardList::SortRank() {
continue; continue;
} }
while (it->GetNext() != NULL && Read()->Rank() > it->GetNext()->Rank()) { while (it->GetNext() != NULL && Read()->GetRank() > it->GetNext()->GetRank()) {
//place the iterator just before the position to insert the card //place the iterator just before the position to insert the card
it = it->GetNext(); it = it->GetNext();
} }
@@ -243,7 +243,7 @@ Card* CardList::Head() {
return headCard; return headCard;
} }
void CardList::DrawAll(SDL_Surface* dest) { void CardList::DrawTo(SDL_Surface* dest) {
for (iterator it = headCard;it != NULL;it = it->GetNext()) for (iterator it = headCard;it != NULL;it = it->GetNext())
it->Draw(dest); it->DrawTo(dest);
} }

View File

@@ -1,7 +1,7 @@
/* File Name: card_list.h /* File Name: card_list.h
* Author: Kayne Ruse * Author: Kayne Ruse
* Date (dd/mm/yyyy): 05/06/2011 * Date (dd/mm/yyyy): 21/01/2013
* Copyright: (c) Kayne Ruse 2011, 2012 * Copyright: (c) Kayne Ruse 2011, 2012, 2013
* *
* This software is provided 'as-is', without any express or implied * This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages * warranty. In no event will the authors be held liable for any damages
@@ -23,7 +23,7 @@
* distribution. * distribution.
* *
* Description: * Description:
* Designed for Project Hearts, 4th try. * A linked list of playing cards.
*/ */
#ifndef KR_CARDLIST_H_ #ifndef KR_CARDLIST_H_
#define KR_CARDLIST_H_ #define KR_CARDLIST_H_
@@ -47,7 +47,7 @@ public:
int Size(); int Size();
Card* Head(); Card* Head();
void DrawAll(SDL_Surface*); void DrawTo(SDL_Surface*);
typedef Card* iterator; typedef Card* iterator;
private: private:

View File

@@ -1,7 +1,7 @@
/* File Name: deck.cpp /* File Name: deck.cpp
* Author: Kayne Ruse * Author: Kayne Ruse
* Date (dd/mm/yyyy): 05/06/2011 * Date (dd/mm/yyyy): 21/01/2013
* Copyright: (c) Kayne Ruse 2011, 2012 * Copyright: (c) Kayne Ruse 2011, 2012, 2013
* *
* This software is provided 'as-is', without any express or implied * This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages * warranty. In no event will the authors be held liable for any damages
@@ -23,55 +23,43 @@
* distribution. * distribution.
* *
* Description: * Description:
* Designed for Project Hearts, 4th try. * Create and destroy the cards in the game, and report if any are missing.
*/ */
#include <iostream>
#include "deck.h" #include "deck.h"
using namespace std;
#include <stdexcept>
Deck::Deck() { Deck::Deck() {
faceSurface = NULL; count = 0;
backSurface = NULL;
} }
Deck::~Deck() { Deck::~Deck() {
DeleteAll(); Quit();
if (faceSurface != NULL)
SDL_FreeSurface(faceSurface);
if (backSurface != NULL)
SDL_FreeSurface(backSurface);
} }
void Deck::Init(const char* faceName, const char* backName) { void Deck::Init(const char* faceName, const char* backName) {
//Create and setup the surfaces, with error checking face.LoadSurface(faceName);
faceSurface = SDL_LoadBMP(faceName); back.LoadSurface(backName);
if (faceSurface == NULL) { //exit if there are already cards in the game
cerr << "Error in Deck::Init(faceName,backName)" << endl; if (count != 0)
cerr << "SDL_LoadBMP() returned NULL" << endl;
cerr << "faceName: " << faceName << endl;
return; return;
}
backSurface = SDL_LoadBMP(backName);
if (backSurface == NULL) {
cerr << "Error in Deck::Init(faceName,backName)" << endl;
cerr << "SDL_LoadBMP() returned NULL" << endl;
cerr << "backName: " << backName << endl;
return;
}
SDL_SetColorKey(faceSurface,SDL_SRCCOLORKEY,SDL_MapRGB(faceSurface->format,255,0,255));
SDL_SetColorKey(backSurface,SDL_SRCCOLORKEY,SDL_MapRGB(backSurface->format,255,0,255));
//Create the cards //Create the cards
for (int s = 1; s <= 4; s++) for (int s = 1; s <= 4; s++) {
for (int r = 1; r <= 13; r++) for (int r = 1; r <= 13; r++) {
Receive(new Card(s,r,faceSurface,backSurface)); Receive(new Card(s,r,face.GetSurface(),back.GetSurface()));
count++;
}
}
} }
void Deck::DeleteAll() { void Deck::Quit() {
while(Head() != NULL) while(Head() != NULL) {
delete Pass(); delete Pass();
count--;
}
if (count != 0)
throw(std::runtime_error("Memory leak: Some cards are unnacounted for"));
} }

View File

@@ -1,7 +1,7 @@
/* File Name: deck.h /* File Name: deck.h
* Author: Kayne Ruse * Author: Kayne Ruse
* Date (dd/mm/yyyy): 05/06/2011 * Date (dd/mm/yyyy): 21/01/2013
* Copyright: (c) Kayne Ruse 2011, 2012 * Copyright: (c) Kayne Ruse 2011, 2012, 2013
* *
* This software is provided 'as-is', without any express or implied * This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages * warranty. In no event will the authors be held liable for any damages
@@ -23,13 +23,15 @@
* distribution. * distribution.
* *
* Description: * Description:
* Designed for Project Hearts, 4th try. * Create and destroy the cards in the game, and report if any are missing.
*/ */
#ifndef KR_DECK_H_ #ifndef KR_DECK_H_
#define KR_DECK_H_ #define KR_DECK_H_
#include "SDL.h"
#include "card_list.h" #include "card_list.h"
#include "image.hpp"
class Deck : public CardList { class Deck : public CardList {
public: public:
/* Public access members */ /* Public access members */
@@ -37,11 +39,13 @@ public:
~Deck(); ~Deck();
void Init(const char* faceName, const char* backName); void Init(const char* faceName, const char* backName);
void DeleteAll(); void Quit();
private: private:
/* Private access members */ /* Private access members */
SDL_Surface* faceSurface; Image face;
SDL_Surface* backSurface; Image back;
int count;
}; };
#endif #endif

View File

@@ -26,23 +26,35 @@
* Designed for Project Hearts, 4th try. * Designed for Project Hearts, 4th try.
*/ */
#include <iostream> #include <iostream>
#include <time.h>
#include <sstream>
#include "hearts_engine.h" #include "hearts_engine.h"
using namespace std; using namespace std;
#define CASE break; case #define CASE break; case
string itos(int i) {
ostringstream ostr;
ostr << i;
return ostr.str();
}
//------------------------- //-------------------------
//Public access members //Public access members
//------------------------- //-------------------------
HeartsEngine::HeartsEngine() { HeartsEngine::HeartsEngine() {
mImage.Add("heart","rsc\\heart.bmp",32,32,64,64); heartSprite.LoadSurface("rsc/heart.bmp");
heartSprite.SetClipW(64);
mAudio.Init(0,MIX_DEFAULT_FREQUENCY,MIX_DEFAULT_FORMAT,1,1024); deck.Init("rsc/cards.bmp","rsc/back.bmp");
mAudio.Add("knock","rsc\\knock.wav");
mAudio.Add("glass","rsc\\glass_break.wav");
deck.Init("rsc\\cards.bmp","rsc\\back.bmp"); button.LoadSurface("rsc/button.bmp");
button.LoadFontSurface("rsc/pk_white_8.bmp");
font.LoadSurface("rsc/pk_white_8.bmp");
button.SetX(300);
button.SetY(300);
player[0] = new PlayerUser(); player[0] = new PlayerUser();
player[1] = new PlayerAI(); player[1] = new PlayerAI();
@@ -60,6 +72,10 @@ HeartsEngine::HeartsEngine() {
player[1]->SetPositions(0, ScreenHeight()/2 - 169, 0,20); player[1]->SetPositions(0, ScreenHeight()/2 - 169, 0,20);
player[2]->SetPositions(ScreenWidth()/2-156, 0, 20,0); player[2]->SetPositions(ScreenWidth()/2-156, 0, 20,0);
player[3]->SetPositions(ScreenWidth()-73, ScreenHeight()/2 - 169, 0,20); player[3]->SetPositions(ScreenWidth()-73, ScreenHeight()/2 - 169, 0,20);
//randomization
srand(time(NULL));
rand(); rand(); rand();
} }
HeartsEngine::~HeartsEngine() { HeartsEngine::~HeartsEngine() {
@@ -67,14 +83,22 @@ HeartsEngine::~HeartsEngine() {
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
delete player[i]; delete player[i];
heartSprite.FreeSurface();
} }
//------------------------- //-------------------------
//Engine members //Engine members
//------------------------- //-------------------------
void HeartsEngine::MouseButtonDown(SDL_MouseButtonEvent& button) { void HeartsEngine::MouseMotion(SDL_MouseMotionEvent& motion) {
BaseEngine::MouseButtonDown(button); BaseEngine::MouseMotion(motion);
button.MouseMotion(motion);
}
void HeartsEngine::MouseButtonDown(SDL_MouseButtonEvent& butt) {
BaseEngine::MouseButtonDown(butt);
button.MouseButtonDown(butt);
switch(gamePhase) { switch(gamePhase) {
CASE SWAP: CASE SWAP:
@@ -85,6 +109,11 @@ void HeartsEngine::MouseButtonDown(SDL_MouseButtonEvent& button) {
} }
} }
void HeartsEngine::MouseButtonUp(SDL_MouseButtonEvent& butt) {
BaseEngine::MouseButtonUp(butt);
button.MouseButtonUp(butt);
}
void HeartsEngine::Process() { void HeartsEngine::Process() {
switch(gamePhase) { switch(gamePhase) {
CASE SETUP: SetupPhase(); CASE SETUP: SetupPhase();
@@ -97,11 +126,25 @@ void HeartsEngine::Process() {
void HeartsEngine::Draw() { void HeartsEngine::Draw() {
SDL_FillRect(screen,NULL,SDL_MapRGB(screen->format,0,128,0)); SDL_FillRect(screen,NULL,SDL_MapRGB(screen->format,0,128,0));
mImage.DrawAll(screen); heartSprite.DrawTo(screen, 32, 32);
switch(gamePhase) { switch(gamePhase) {
case SETUP: case SETUP:
case SWAP: case SWAP:
if (player[0]->CheckSwapCards()) {
switch(rotation) {
case Rotation::LEFT:
button.SetText("Pass Left");
break;
case Rotation::RIGHT:
button.SetText("Pass Right");
break;
case Rotation::ACROSS:
button.SetText("Pass Across");
break;
}
button.DrawTo(screen);
}
case TRICK: case TRICK:
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
player[i]->DrawHand(screen); player[i]->DrawHand(screen);
@@ -111,6 +154,28 @@ void HeartsEngine::Draw() {
case SCORE: case SCORE:
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
player[i]->DrawTricks(screen); player[i]->DrawTricks(screen);
button.SetText("Continue");
button.DrawTo(screen);
//I know this sucks
for (int i = 0; i < 4; i++) {
if (winner == i) {
font.DrawStringTo(
string() + "Player " + itos(i+1) + ": " + itos(player[i]->Score()) + " - " + itos(player[i]->Wins()) + " wins <-- Winner!!",
screen,
300,
200 + font.GetCharH() * i
);
}
else {
font.DrawStringTo(
string() + "Player " + itos(i+1) + ": " + itos(player[i]->Score()) + " - " + itos(player[i]->Wins()) + " wins",
screen,
300,
200 + font.GetCharH() * i
);
}
}
break; break;
} }
} }
@@ -140,7 +205,7 @@ void HeartsEngine::SetupPhase() {
firstPlayer = -1; firstPlayer = -1;
trickCount = 0; trickCount = 0;
heartsBroken = false; heartsBroken = false;
mImage["heart"]->SetClipX(0); heartSprite.SetClipX(0);
if (rotation == NONE) { if (rotation == NONE) {
CalcFirst(); CalcFirst();
@@ -155,7 +220,7 @@ void HeartsEngine::SetupPhase() {
} }
void HeartsEngine::SwapPhase() { void HeartsEngine::SwapPhase() {
if (!keyboard[SDLK_F1]) if (button.GetState() != Button::State::PRESSED)
return; return;
if (!player[0]->CheckSwapCards()) if (!player[0]->CheckSwapCards())
@@ -199,47 +264,41 @@ void HeartsEngine::TrickPhase() {
ResetPositions(); ResetPositions();
CalcScores(); CalcScores();
gamePhase = SCORE; gamePhase = SCORE;
for (int i = 0; i < 4; i++) {
cout << "Player " << i << ": " << player[i]->Score() << endl;//tmp...
}
cout << endl;
} }
} }
void HeartsEngine::ScorePhase() { void HeartsEngine::ScorePhase() {
//end of game; temporary functionality... //end of game; temporary functionality...
if (player[0]->Score() >= 100 || if ((player[0]->Score() >= 100 ||
player[1]->Score() >= 100 || player[1]->Score() >= 100 ||
player[2]->Score() >= 100 || player[2]->Score() >= 100 ||
player[3]->Score() >= 100) player[3]->Score() >= 100) && winner == -1)
{ {
cout << "GAME OVER" << endl; winner = 0;
int winner = 0;
//find the winner
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
if (player[i]->Score() < player[winner]->Score()) { if (player[i]->Score() < player[winner]->Score()) {
winner = i; winner = i;
} }
} }
cout << "Winner is: " << winner << endl;
cout << endl;
//award the winner
player[winner]->Wins(1); player[winner]->Wins(1);
for (int i = 0; i < 4; i++) }
cout << "Player " << i << " wins: " << player[i]->Wins() << endl;
cout << endl; //wait for input
if (button.GetState() == Button::State::PRESSED) {
gamePhase = CLEANUP;
//reset all values //reset the game
if (winner != -1) {
winner = -1;
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
player[i]->Score( -player[i]->Score() ); player[i]->Score( -player[i]->Score() );
rotation = NONE; rotation = NONE;
} }
}
//10 second delay
if (SDL_GetTicks() - timeTick > 10000 || keyboard[SDLK_F1])//button...
gamePhase = CLEANUP;
} }
void HeartsEngine::CleanupPhase() { void HeartsEngine::CleanupPhase() {
@@ -259,7 +318,6 @@ void HeartsEngine::CleanupPhase() {
void HeartsEngine::PlayBeforePhase() { void HeartsEngine::PlayBeforePhase() {
if (firstPlayer != 0) { if (firstPlayer != 0) {
mAudio.Play("knock");
for (int i = firstPlayer; i < 4; i++) { for (int i = firstPlayer; i < 4; i++) {
bool heartSound = heartsBroken; bool heartSound = heartsBroken;
Card* c = ((PlayerAI*)(player[i]))->PassPlayCard(table.GetLeadingSuit(firstPlayer),trickCount,heartsBroken); Card* c = ((PlayerAI*)(player[i]))->PassPlayCard(table.GetLeadingSuit(firstPlayer),trickCount,heartsBroken);
@@ -271,8 +329,7 @@ void HeartsEngine::PlayBeforePhase() {
cerr << "Player index: " << i << endl; cerr << "Player index: " << i << endl;
} }
if (heartSound != heartsBroken) { if (heartSound != heartsBroken) {
mImage["heart"]->SetClipX(64); heartSprite.SetClipX(64);
mAudio.Play("glass");
} }
} }
} }
@@ -288,14 +345,12 @@ void HeartsEngine::PlayPlayerPhase() {
playPhase = AFTER; playPhase = AFTER;
} }
if (heartSound != heartsBroken) { if (heartSound != heartsBroken) {
mImage["heart"]->SetClipX(64); heartSprite.SetClipX(64);
mAudio.Play("glass");
} }
} }
} }
void HeartsEngine::PlayAfterPhase() { void HeartsEngine::PlayAfterPhase() {
mAudio.Play("knock");
int max = (firstPlayer == 0)? 4:firstPlayer; int max = (firstPlayer == 0)? 4:firstPlayer;
for (int i = 1; i < max; i++) { for (int i = 1; i < max; i++) {
@@ -309,8 +364,7 @@ void HeartsEngine::PlayAfterPhase() {
cerr << "Player index: " << i << endl; cerr << "Player index: " << i << endl;
} }
if (heartSound != heartsBroken) { if (heartSound != heartsBroken) {
mImage["heart"]->SetClipX(64); heartSprite.SetClipX(64);
mAudio.Play("glass");
} }
} }
@@ -372,7 +426,7 @@ void HeartsEngine::CalcScores() {
if (card == NULL) if (card == NULL)
break; break;
if (card->Suit() == Card::HEARTS) if (card->GetSuit() == Card::HEARTS)
tally++; tally++;
if (ISCARD(card,QUEEN,SPADES)) if (ISCARD(card,QUEEN,SPADES))

View File

@@ -27,13 +27,16 @@
*/ */
#ifndef KR_HEARTSENGINE_H_ #ifndef KR_HEARTSENGINE_H_
#define KR_HEARTSENGINE_H_ #define KR_HEARTSENGINE_H_
#include "base_engine.h" #include "base_engine.h"
#include "image_manager.h"
#include "audio_manager.h" #include "image.hpp"
#include "deck.h" #include "deck.h"
#include "player_ai.h" #include "player_ai.h"
#include "player_user.h" #include "player_user.h"
#include "table.h" #include "table.h"
#include "button.hpp"
#include "raster_font.hpp"
class HeartsEngine : public KAGE::BaseEngine { class HeartsEngine : public KAGE::BaseEngine {
public: public:
@@ -42,13 +45,14 @@ public:
~HeartsEngine(); ~HeartsEngine();
private: private:
/* Engine members */ /* Engine members */
void MouseMotion (SDL_MouseMotionEvent& motion);
void MouseButtonDown (SDL_MouseButtonEvent& button); void MouseButtonDown (SDL_MouseButtonEvent& button);
void MouseButtonUp (SDL_MouseButtonEvent& button);
void Process (); void Process ();
void Draw (); void Draw ();
/* KAGE Managers */ /* KAGE Managers */
KAGE::ImageManager mImage; Image heartSprite;
KAGE::AudioManager mAudio;
/* Game phase members */ //TODO: "phases" /* Game phase members */ //TODO: "phases"
void SetupPhase(); void SetupPhase();
@@ -74,6 +78,9 @@ private:
}rotation; }rotation;
/* Game members */ /* Game members */
Button button;
RasterFont font;
Deck deck; Deck deck;
Player *player[4]; Player *player[4];
Table table; Table table;
@@ -83,6 +90,8 @@ private:
bool heartsBroken; bool heartsBroken;
int timeTick; int timeTick;
int winner = -1;
/* Utility members */ /* Utility members */
void ResetPositions(); void ResetPositions();
void ResetFaces(); void ResetFaces();
@@ -90,6 +99,4 @@ private:
void CalcScores(); void CalcScores();
}; };
START(HeartsEngine)
#endif #endif

View File

@@ -1,7 +1,4 @@
/* File Name: image.cpp /* Copyright: (c) Kayne Ruse 2013
* Author: Kayne Ruse
* Date (dd/mm/yyyy): 20/06/2011
* Copyright: (c) Kayne Ruse 2011, 2012
* *
* This software is provided 'as-is', without any express or implied * This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages * warranty. In no event will the authors be held liable for any damages
@@ -21,154 +18,128 @@
* *
* 3. This notice may not be removed or altered from any source * 3. This notice may not be removed or altered from any source
* distribution. * distribution.
*
* Description:
* The Image class, a wrapper for SDL_Surface and other drawing functionality.
* Part of the KAGE Game Engine.
*/ */
#include <iostream> #include "image.hpp"
#include "image.h"
using namespace std;
using namespace KAGE;
//------------------------- #include <stdexcept>
//Public access members #include <sstream>
//-------------------------
Image::Image(const char* fileName, int x, int y, int w, int h): Image& Image::operator=(Image const& rhs) {
localSurface(true) //don't screw yourself
{ if (this == &rhs) {
//Create a local surface from a file return *this;
surface = SDL_LoadBMP(fileName);
if (surface == NULL) {
cout << "Error in Image::Image()" << endl;
cout << "SDL_LoadBMP() returned NULL" << endl;
cout << "fileName: " << fileName << endl;
return;
} }
SetColorKey(255,0,255); FreeSurface();
Init(x,y,0,0,w,h);
//Copy the other Image's stuff
surface = rhs.surface;
clip = rhs.clip;
local = false;
} }
Image::Image(SDL_Surface* surf, int x, int y, int w, int h): Image& Image::operator=(Image&& rhs) {
localSurface(false) //don't screw yourself
{ if (this == &rhs) {
//Use a surface passed by the calling function return *this;
surface = surf;
Init(x,y,0,0,w,h);
} }
void Image::Init(int x, int y, int sx, int sy, int sw, int sh) { FreeSurface();
//Set up the variables
dclip.x = x; //Steal the other Image's stuff
dclip.y = y; surface = rhs.surface;
sclip.x = sx; clip = rhs.clip;
sclip.y = sy; local = rhs.local;
sclip.w = (sw == 0) ? surface->w : sw;
sclip.h = (sh == 0) ? surface->h : sh; rhs.surface = nullptr;
rhs.clip = {0, 0, 0, 0};
rhs.local = false;
} }
Image::~Image() { SDL_Surface* Image::LoadSurface(std::string fname) {
if (localSurface) FreeSurface();
SDL_FreeSurface(surface); SDL_Surface* p = SDL_LoadBMP(fname.c_str());
if (!p) {
std::ostringstream os;
os << "Failed to load file: " << fname;
throw(std::runtime_error(os.str()));
} }
surface = p;
//------------------------- clip = {0, 0, (Uint16)surface->w, (Uint16)surface->h};
//Graphical members local = true;
//------------------------- SetTransparentColor(255, 0, 255); //default
void Image::Draw(SDL_Surface* dest, int camX, int camY) {
SDL_Rect tmp = dclip;
tmp.x += camX;
tmp.y += camY;
SDL_BlitSurface(surface,&sclip,dest,&tmp);
}
int Image::SetColorKey(int red, int green, int blue) {
if (localSurface)
return SDL_SetColorKey(surface,SDL_SRCCOLORKEY,SDL_MapRGB(surface->format,red,green,blue));
else
return -2;
}
int Image::ClearColorKey() {
if (localSurface)
return SDL_SetColorKey(surface,0,0);
else
return -2;
}
//-------------------------
//Accessors and mutators
//-------------------------
void Image::SetPos(int x, int y) {
dclip.x = x;
dclip.y = y;
}
int Image::SetX(int x) {
return dclip.x = x;
}
int Image::SetY(int y) {
return dclip.y = y;
}
int Image::SetClipX(int x) {
return sclip.x = x;
}
int Image::SetClipY(int y) {
return sclip.y = y;
}
int Image::SetWidth(int w) {
return sclip.w = w;
}
int Image::SetHeight(int h) {
return sclip.h = h;
}
int Image::GetX() {
return dclip.x;
}
int Image::GetY() {
return dclip.y;
}
int Image::GetClipX() {
return sclip.x;
}
int Image::GetClipY() {
return sclip.y;
}
int Image::GetWidth() {
return sclip.w;
}
int Image::GetHeight() {
return sclip.h;
}
//-------------------------
//Protected access members
//-------------------------
SDL_Surface* Image::SetSurface(SDL_Surface* surf) {
return surface = surf;
}
SDL_Surface* Image::GetSurface() {
return surface; return surface;
} }
bool Image::LocalSurface() { SDL_Surface* Image::CreateSurface(Uint16 w, Uint16 h) {
return localSurface; FreeSurface();
Uint32 rmask, gmask, bmask, amask;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
rmask = 0xff000000;
gmask = 0x00ff0000;
bmask = 0x0000ff00;
amask = 0x000000ff;
#else
rmask = 0x000000ff;
gmask = 0x0000ff00;
bmask = 0x00ff0000;
amask = 0xff000000;
#endif
SDL_Surface* p = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, rmask, gmask, bmask, amask);
if (!p) {
throw(std::runtime_error("Failed to create Image surface"));
}
surface = p;
clip = {0, 0, (Uint16)surface->w, (Uint16)surface->h};
local = true;
SetTransparentColor(255, 0, 255); //default
return surface;
}
SDL_Surface* Image::SetSurface(SDL_Surface* p) {
FreeSurface();
if (!p) {
throw(std::invalid_argument("No surface pointer provided"));
}
surface = p;
clip = {0, 0, (Uint16)surface->w, (Uint16)surface->h};
local = false;
return surface;
}
void Image::FreeSurface() {
if (local) {
SDL_FreeSurface(surface);
local = false;
}
surface = nullptr;
clip = {0, 0, 0, 0};
}
void Image::DrawTo(SDL_Surface* dest, Sint16 x, Sint16 y) {
if (!surface) {
throw(std::logic_error("No image surface to draw"));
}
SDL_Rect sclip = clip, dclip = {x,y};
SDL_BlitSurface(surface, &sclip, dest, &dclip);
}
void Image::SetTransparentColor(Uint8 r, Uint8 g, Uint8 b) {
if (!surface) {
throw(std::logic_error("Failed to set the transparent color"));
}
if (!local) {
throw(std::logic_error("Cannot set the transparent color of a non-local surface"));
}
SDL_SetColorKey(surface, SDL_SRCCOLORKEY, SDL_MapRGB(surface->format, r, g, b));
}
void Image::ClearTransparentColor() {
if (!surface) {
throw(std::logic_error("Failed to clear the transparent color"));
}
if (!local) {
throw(std::logic_error("Cannot clear the transparent color of a non-local surface"));
}
SDL_SetColorKey(surface, 0, 0);
} }

View File

@@ -1,79 +0,0 @@
/* File Name: image.h
* Author: Kayne Ruse
* Date (dd/mm/yyyy): 20/06/2011
* Copyright: (c) Kayne Ruse 2011, 2012
*
* 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, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* Description:
* The Image class, a wrapper for SDL_Surface and other drawing functionality.
* Part of the KAGE Game Engine.
*/
#ifndef KR_KAGE_IMAGE_H_
#define KR_KAGE_IMAGE_H_
#include "SDL.h"
namespace KAGE {
class Image {
public:
/* Public access members */
Image(const char* fileName, int x = 0, int y = 0, int w = 0, int h = 0);
Image(SDL_Surface* surface, int x = 0, int y = 0, int w = 0, int h = 0);
~Image();
/* Graphical members */
virtual void Draw(SDL_Surface* dest, int camX = 0, int camY = 0);
int SetColorKey(int red, int green, int blue);
int ClearColorKey();
/* Accessors and mutators */
virtual void SetPos(int x, int y);
virtual int SetX(int);
virtual int SetY(int);
virtual int SetClipX(int);
virtual int SetClipY(int);
virtual int SetWidth(int);
virtual int SetHeight(int);
virtual int GetX();
virtual int GetY();
virtual int GetClipX();
virtual int GetClipY();
virtual int GetWidth();
virtual int GetHeight();
protected:
/* Protected access members */
void Init(int x, int y, int sx, int sy, int sw, int sh);
SDL_Surface* SetSurface (SDL_Surface* surf);
SDL_Surface* GetSurface ();
bool LocalSurface ();
private:
/* Private access members */
SDL_Surface* surface;
SDL_Rect sclip;
SDL_Rect dclip;
const bool localSurface;
};
}
#endif

73
Hearts/image.hpp Normal file
View File

@@ -0,0 +1,73 @@
/* Copyright: (c) Kayne Ruse 2013
*
* 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, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*/
#ifndef IMAGE_HPP_
#define IMAGE_HPP_
#include "SDL/SDL.h"
#include <string>
class Image {
public:
Image() = default;
Image(Image const& rhs) { *this = rhs; }
Image(Image&& rhs) { *this = std::move(rhs); }
Image(std::string fname) { LoadSurface(fname); }
Image(Uint16 w, Uint16 h) { CreateSurface(w, h); }
Image(SDL_Surface* p) { SetSurface(p); }
~Image() { FreeSurface(); }
Image& operator=(Image const&);
Image& operator=(Image&&);
SDL_Surface* LoadSurface(std::string fname);
SDL_Surface* CreateSurface(Uint16 w, Uint16 h);
SDL_Surface* SetSurface(SDL_Surface*);
SDL_Surface* GetSurface() const { return surface; }
void FreeSurface();
void DrawTo(SDL_Surface* const, Sint16 x, Sint16 y);
//Clip handlers
SDL_Rect SetClip(SDL_Rect r) { return clip = r; }
SDL_Rect GetClip() const { return clip; }
Sint16 SetClipX(Sint16 x) { return clip.x = x; }
Sint16 SetClipY(Sint16 y) { return clip.y = y; }
Uint16 SetClipW(Uint16 w) { return clip.w = w; }
Uint16 SetClipH(Uint16 h) { return clip.h = h; }
Sint16 GetClipX() const { return clip.x; }
Sint16 GetClipY() const { return clip.y; }
Uint16 GetClipW() const { return clip.w; }
Uint16 GetClipH() const { return clip.h; }
bool GetLocal() const { return local; }
void SetTransparentColor(Uint8 r, Uint8 g, Uint8 b);
void ClearTransparentColor();
protected:
SDL_Surface* surface = nullptr;
SDL_Rect clip = {0, 0, 0, 0};
bool local = false;
};
#endif

View File

@@ -1,74 +0,0 @@
/* File Name: image_manager.cpp
* Author: Kayne Ruse
* Date (dd/mm/yyyy): 20/06/2011
* Copyright: (c) Kayne Ruse 2011, 2012
*
* 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, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* Description:
* The Image Manager creates, organises and cleans up the Images in the game.
* Part of the KAGE Game Engine.
*/
#include <iostream>
#include "image_manager.h"
using namespace std;
using namespace KAGE;
//-------------------------
//Public access members
//-------------------------
Image* ImageManager::Add(const char* name,const char* fName, int x, int y, int w, int h) {
if (Exists(name)) {
cout << "Error in ImageManager::Add(name,fName)" << endl;
cout << "An Image of that name already exists" << endl;
cout << "name: " << name << endl;
return NULL;
}
return NamedManager::Add(name,new Image(fName,x,y,w,h));
}
Image* ImageManager::Add(const char* name,SDL_Surface* surface, int x, int y, int w, int h) {
if (Exists(name)) {
cout << "Error in ImageManager::Add(name,surface)" << endl;
cout << "An Image of that name already exists" << endl;
cout << "name: " << name << endl;
return NULL;
}
return NamedManager::Add(name,new Image(surface,x,y,w,h));
}
Image* ImageManager::Add(const char *name,Image* image) {
if (Exists(name)) {
cout << "Error in ImageManager::Add(name,image)" << endl;
cout << "An Image of that name already exists" << endl;
cout << "name: " << name << endl;
return NULL;
}
return NamedManager::Add(name,image);
}
void ImageManager::DrawAll(SDL_Surface* dest, int camX, int camY) {
for (MapType::iterator it = mapList.begin(); it != mapList.end(); it++)
it->second->Draw(dest,camX,camY);
}

View File

@@ -1,7 +1,4 @@
/* File Name: sound.h /* Copyright: (c) Kayne Ruse 2013
* Author: Kayne Ruse
* Date (dd/mm/yyyy): 13/06/2011
* Copyright: (c) Kayne Ruse 2011, 2012
* *
* This software is provided 'as-is', without any express or implied * This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages * warranty. In no event will the authors be held liable for any damages
@@ -21,33 +18,28 @@
* *
* 3. This notice may not be removed or altered from any source * 3. This notice may not be removed or altered from any source
* distribution. * distribution.
*
* Description:
* The Sound class, a wrapper for Mix_Chunk and other sound functionality.
* Part of the KAGE Game Engine.
*/ */
#ifndef KR_KAGE_SOUND_H_ #include "hearts_engine.h"
#define KR_KAGE_SOUND_H_
#include "SDL_mixer.h" #include <stdexcept>
#include <iostream>
namespace KAGE { using namespace std;
class Sound {
public:
/* Public access members */
Sound(const char* fName);
~Sound();
/* Accessors and mutators */
int Play(int channel = -1,int loop = 0);
int Volume(int volume = -1);
protected:
/* Protected access members */
Mix_Chunk* GetMixChunk();
private:
/* Private access members */
Mix_Chunk* chunk;
};
}
int main(int, char**) {
#ifdef DEBUG
cout << "Beginning program" << endl;
#endif #endif
try {
HeartsEngine app;
app.Start(true);
}
catch(exception& e) {
cerr << "Fatal exception thrown: " << e.what() << endl;
return 1;
}
#ifdef DEBUG
cout << "Clean exit" << endl;
#endif
return 0;
}

53
Hearts/makefile Normal file
View File

@@ -0,0 +1,53 @@
#libraries
ifeq ($(OS),Windows_NT)
LIBS+=-lmingw32
endif
LIBS+=-lSDLmain -lSDL
#flags
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
ifeq ($(shell uname), Linux)
#read data about the current install
CXXFLAGS+=$(shell sdl-config --cflags --static-libs)
endif
#source
CXXSRC=$(wildcard *.cpp)
CSRC=$(wildcard *.c)
#objects
OBJDIR=obj
OBJ+=$(addprefix $(OBJDIR)/,$(CXXSRC:.cpp=.o))
OBJ+=$(addprefix $(OBJDIR)/,$(CSRC:.c=.o))
#output
OUTDIR=../out
OUT=$(addprefix $(OUTDIR)/,Hearts)
#targets
all: $(OBJ) $(OUT)
$(CXX) $(CXXFLAGS) -o $(OUT) $(OBJ) $(LIBS)
$(OBJ): | $(OBJDIR)
$(OUT): | $(OUTDIR)
$(OBJDIR):
mkdir $(OBJDIR)
$(OUTDIR):
mkdir $(OUTDIR)
$(OBJDIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
clean:
ifeq ($(OS),Windows_NT)
$(RM) *.o *.a *.exe
else ifeq ($(shell uname), Linux)
find . -type f -name '*.o' -exec rm -f -r -v {} \;
find . -type f -name '*.a' -exec rm -f -r -v {} \;
rm -f -v $(OUT)
endif
rebuild: clean all

View File

@@ -1,116 +0,0 @@
/* File Name: music.cpp
* Author: Kayne Ruse
* Date (dd/mm/yyyy): 21/06/2011
* Copyright: (c) Kayne Ruse 2011, 2012
*
* 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, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* Description:
* The Music class, a wrapper for Mix_Music and other sound functionality.
* Part of the KAGE Game Engine.
*/
#include <iostream>
#include "music.h"
using namespace std;
using namespace KAGE;
//-------------------------
//Public access members
//-------------------------
Music::Music() {
music = NULL;
}
Music::~Music() {
Free();
}
//-------------------------
//Accessors and mutators
//-------------------------
int Music::Load(const char* fName) {
Free();
music = Mix_LoadMUS(fName);
if (music == NULL) {
cout << "Error in Music::Load()" << endl;
cout << "Mix_LoadMUS() returned NULL" << endl;
cout << "fName: " << fName << endl;
return -1;
}
return 0;
}
void Music::Free() {
if (music != NULL) {
Mix_FreeMusic(music);
music = NULL;
}
}
int Music::Play(int loop) {
if (music == NULL) {
cout << "Error in Music::Play()" << endl;
cout << "There is no music loaded" << endl;
return -2;
}
return Mix_PlayMusic(music,loop);
}
void Music::Halt() {
Mix_HaltMusic();
}
int Music::Playing() {
return Mix_PlayingMusic();
}
void Music::Pause() {
Mix_PauseMusic();
}
void Music::Resume() {
Mix_ResumeMusic();
}
int Music::Paused() {
return Mix_PausedMusic();
}
void Music::Rewind() {
Mix_RewindMusic();
}
int Music::Volume(int volume) {
return Mix_VolumeMusic(volume);
}
//-------------------------
//Protected access members
//-------------------------
Mix_Music* Music::GetMixMusic() {
return music;
}

View File

@@ -1,63 +0,0 @@
/* File Name: music.h
* Author: Kayne Ruse
* Date (dd/mm/yyyy): 21/06/2011
* Copyright: (c) Kayne Ruse 2011, 2012
*
* 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, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* Description:
* The Music class, a wrapper for Mix_Music and other sound functionality.
* Part of the KAGE Game Engine.
*/
#ifndef KR_KAGE_MUSIC_H_
#define KR_KAGE_MUSIC_H_
#include "SDL_mixer.h"
namespace KAGE {
class Music {
public:
/* Public access members */
Music();
~Music();
/* Accessors and mutators */
int Load (const char* fName);
void Free ();
int Play (int loop = -1);
void Halt ();
int Playing ();
void Pause ();
void Resume ();
int Paused ();
void Rewind ();
int Volume (int volume);
protected:
/* Protected access members */
Mix_Music* GetMixMusic();
private:
/* Private access members */
Mix_Music* music;
};
}
#endif

View File

@@ -1,130 +0,0 @@
/* File Name: named_manager.h
* Author: Kayne Ruse
* Date (dd/mm/yyyy): 21/06/2011
* Copyright: (c) Kayne Ruse 2011, 2012
*
* 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, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* Description:
* The NamedManager template class acts as a parent for all of Kage's managers.
* Part of the KAGE Game Engine.
*/
#ifndef KR_KAGE_NAMEDMANAGER_H_
#define KR_KAGE_NAMEDMANAGER_H_
#include <map>
#include <string>
namespace KAGE {
template<typename T>
class NamedManager {
public:
/* Public access members */
~NamedManager ();
T* Get (const char* name);
T* operator[] (const char* name);
T* Remove (const char* name);
void Delete (const char* name);
void DeleteAll ();
bool Exists (const char* name);
int Size ();
protected:
/* Protected access members */
T* Add (const char* name,T* item);
typedef std::map<std::string,T*> MapType;
MapType mapList;
};
}
//-------------------------
//Protected access members
//-------------------------
template<typename T>
T* KAGE::NamedManager<T>::Add(const char* name,T* item) {
if (Exists(name))
return NULL;
return mapList[name] = item;
}
//-------------------------
//Public access members
//-------------------------
template<typename T>
KAGE::NamedManager<T>::~NamedManager() {
DeleteAll();
}
template<typename T>
T* KAGE::NamedManager<T>::Get(const char* name) {
MapType::const_iterator it = mapList.find(name);
if (it != mapList.end())
return it->second;
else
return NULL;
}
template<typename T>
T* KAGE::NamedManager<T>::operator[](const char* name) {
return Get(name);
}
template<typename T>
T* KAGE::NamedManager<T>::Remove(const char* name) {
MapType::const_iterator it = mapList.find(name);
if (it == mapList.end())
return NULL;
T* ret = it->second;
mapList.erase(it);
return ret;
}
template<typename T>
void KAGE::NamedManager<T>::Delete(const char* name) {
MapType::const_iterator it = mapList.find(name);
if (it != mapList.end()) {
delete it->second;
mapList.erase(it);
}
}
template<typename T>
void KAGE::NamedManager<T>::DeleteAll() {
for (MapType::iterator it = mapList.begin(); it != mapList.end(); it++)
delete it->second;
mapList.clear();
}
template<typename T>
bool KAGE::NamedManager<T>::Exists(const char* name) {
MapType::const_iterator it = mapList.find(name);
return it != mapList.end();
}
template<typename T>
int KAGE::NamedManager<T>::Size() {
return mapList.size();
}
#endif

View File

@@ -104,7 +104,7 @@ void Player::ShiftCard(int index, int dirX, int dirY) {
void Player::SetFaces(int face) { void Player::SetFaces(int face) {
for (CardList::iterator it = hand.Head(); it != NULL; it = it->GetNext()) for (CardList::iterator it = hand.Head(); it != NULL; it = it->GetNext())
it->SetFace(face); it->SetFaceState(face);
} }
void Player::SetPositions(int _posX, int _posY, int _dirX, int _dirY) { void Player::SetPositions(int _posX, int _posY, int _dirX, int _dirY) {
@@ -131,7 +131,7 @@ void Player::SetTrickPositions() {
tricks.Sort(); tricks.Sort();
for (int i = 0; i < tricks.Size(); i++) { for (int i = 0; i < tricks.Size(); i++) {
if (tricks.Read(i)->Suit() != Card::HEARTS && !ISCARD(tricks.Read(i),QUEEN,SPADES)) if (tricks.Read(i)->GetSuit() != Card::HEARTS && !ISCARD(tricks.Read(i),QUEEN,SPADES))
continue; continue;
tricks.Read(i)->SetPos(x,y); tricks.Read(i)->SetPos(x,y);
@@ -141,7 +141,7 @@ void Player::SetTrickPositions() {
} }
void Player::DrawHand(SDL_Surface* dest) { void Player::DrawHand(SDL_Surface* dest) {
Hand()->DrawAll(dest); Hand()->DrawTo(dest);
} }
void Player::DrawTricks(SDL_Surface* dest) { void Player::DrawTricks(SDL_Surface* dest) {
@@ -149,9 +149,9 @@ void Player::DrawTricks(SDL_Surface* dest) {
tricks.Sort(); tricks.Sort();
for (int i = 0; i < tricks.Size(); i++) { for (int i = 0; i < tricks.Size(); i++) {
if (tricks.Read(i)->Suit() != Card::HEARTS && !ISCARD(tricks.Read(i),QUEEN,SPADES)) if (tricks.Read(i)->GetSuit() != Card::HEARTS && !ISCARD(tricks.Read(i),QUEEN,SPADES))
continue; continue;
tricks.Read(i)->Draw(dest); tricks.Read(i)->DrawTo(dest);
} }
} }

View File

@@ -27,7 +27,7 @@
*/ */
#ifndef KR_PLAYER_H_ #ifndef KR_PLAYER_H_
#define KR_PLAYER_H_ #define KR_PLAYER_H_
#include "SDL.h"
#include "card_list.h" #include "card_list.h"
class Player { class Player {

View File

@@ -38,7 +38,7 @@ void PlayerAI::SelectSwapCards(int dirX, int dirY) {
int card = -1; int card = -1;
for (int i = Hand()->Size() - 1; i >= 0; i--) { for (int i = Hand()->Size() - 1; i >= 0; i--) {
if (Hand()->Read(i)->Rank() > Hand()->Read(card)->Rank() && !CheckSwapCards(i) ) { if (Hand()->Read(i)->GetRank() > Hand()->Read(card)->GetRank() && !CheckSwapCards(i) ) {
card = i; card = i;
} }
} }
@@ -75,7 +75,7 @@ Card* PlayerAI::PassPlayFirstTrick(int leadingSuit) {
//follow suit //follow suit
for(int i = 0; i < Hand()->Size()-1; i++) for(int i = 0; i < Hand()->Size()-1; i++)
if (Hand()->Read(i)->Suit() == leadingSuit) if (Hand()->Read(i)->GetSuit() == leadingSuit)
return Hand()->Pass(i); return Hand()->Pass(i);
/* bug: it's possible that if every penalty card is initially dealt the the AI, it'll break /* bug: it's possible that if every penalty card is initially dealt the the AI, it'll break
@@ -88,7 +88,7 @@ Card* PlayerAI::PassPlayFirstTrick(int leadingSuit) {
for (int i = Hand()->Size() -1; i >= 0; i--) {//backwards, to choose the highest rank for (int i = Hand()->Size() -1; i >= 0; i--) {//backwards, to choose the highest rank
c = Hand()->Read(i); c = Hand()->Read(i);
if (c->Suit() != Card::HEARTS && !ISCARD(c,QUEEN,SPADES) ) { if (c->GetSuit() != Card::HEARTS && !ISCARD(c,QUEEN,SPADES) ) {
c = Hand()->Pass(i); c = Hand()->Pass(i);
break; break;
} }
@@ -109,7 +109,7 @@ Card* PlayerAI::PassPlayFollowSuit(int leadingSuit, bool heartsBroken) {
} }
else { else {
for (int i = 0; i < Hand()->Size() -1; i++) { for (int i = 0; i < Hand()->Size() -1; i++) {
if (Hand()->Read(i)->Suit() != Card::HEARTS) { if (Hand()->Read(i)->GetSuit() != Card::HEARTS) {
c = Hand()->Pass(i); c = Hand()->Pass(i);
break; break;
} }
@@ -122,7 +122,7 @@ Card* PlayerAI::PassPlayFollowSuit(int leadingSuit, bool heartsBroken) {
//play the lowest card of the suit //play the lowest card of the suit
for (int i = 0; i < Hand()->Size()-1; i++) for (int i = 0; i < Hand()->Size()-1; i++)
if (Hand()->Read(i)->Suit() == leadingSuit) if (Hand()->Read(i)->GetSuit() == leadingSuit)
return Hand()->Pass(i); return Hand()->Pass(i);
return NULL; return NULL;
@@ -135,7 +135,7 @@ Card* PlayerAI::PassPlayBreakSuit(bool& heartsBroken) {
return Hand()->Pass(i); return Hand()->Pass(i);
//if I have a heart //if I have a heart
if (Hand()->Read( Hand()->Size()-1 )->Suit() == Card::HEARTS) { if (Hand()->Read( Hand()->Size()-1 )->GetSuit() == Card::HEARTS) {
heartsBroken = true; heartsBroken = true;
return Hand()->Pass( Hand()->Size()-1 ); return Hand()->Pass( Hand()->Size()-1 );
} }

View File

@@ -99,16 +99,16 @@ Card* PlayerUser::PassPlayFirstTrick(int card, int leadingSuit) {
} }
//follow suit //follow suit
if (Hand()->Read(card)->Suit() == leadingSuit) //if I've selected the correct suit if (Hand()->Read(card)->GetSuit() == leadingSuit) //if I've selected the correct suit
return Hand()->Pass(card); return Hand()->Pass(card);
//if I haven't selected the correct suit //if I haven't selected the correct suit
for (int i = 0; i < Hand()->Size() -1; i++) for (int i = 0; i < Hand()->Size() -1; i++)
if (Hand()->Read(i)->Suit() == leadingSuit) //The correct suit is in my hand if (Hand()->Read(i)->GetSuit() == leadingSuit) //The correct suit is in my hand
return NULL; return NULL;
//can't follow suit, no penalty cards //can't follow suit, no penalty cards
if (Hand()->Read(card)->Suit() != Card::HEARTS && !ISCARD(Hand()->Read(card),QUEEN,SPADES)) if (Hand()->Read(card)->GetSuit() != Card::HEARTS && !ISCARD(Hand()->Read(card),QUEEN,SPADES))
return Hand()->Pass(card); return Hand()->Pass(card);
return NULL; return NULL;
@@ -121,7 +121,7 @@ Card* PlayerUser::PassPlayFollowSuit(int card, int leadingSuit, bool heartsBroke
if (heartsBroken) if (heartsBroken)
return Hand()->Pass(card); return Hand()->Pass(card);
else { else {
if (Hand()->Read(card)->Suit() != Card::HEARTS) if (Hand()->Read(card)->GetSuit() != Card::HEARTS)
return Hand()->Pass(card); return Hand()->Pass(card);
else else
return NULL; return NULL;
@@ -129,7 +129,7 @@ Card* PlayerUser::PassPlayFollowSuit(int card, int leadingSuit, bool heartsBroke
} }
//if the player is following suit //if the player is following suit
if (Hand()->Read(card)->Suit() == leadingSuit) if (Hand()->Read(card)->GetSuit() == leadingSuit)
return Hand()->Pass(card); return Hand()->Pass(card);
//when the card does not follow suit //when the card does not follow suit
@@ -139,10 +139,10 @@ Card* PlayerUser::PassPlayFollowSuit(int card, int leadingSuit, bool heartsBroke
Card* PlayerUser::PassPlayBreakSuit(int card, int leadingSuit, bool& heartsBroken) { Card* PlayerUser::PassPlayBreakSuit(int card, int leadingSuit, bool& heartsBroken) {
//if the player CAN still follow suit //if the player CAN still follow suit
for (int i = 0; i < Hand()->Size() -1; i++) for (int i = 0; i < Hand()->Size() -1; i++)
if (Hand()->Read(i)->Suit() == leadingSuit) if (Hand()->Read(i)->GetSuit() == leadingSuit)
return NULL; return NULL;
if (Hand()->Read(card)->Suit() == Card::HEARTS) if (Hand()->Read(card)->GetSuit() == Card::HEARTS)
heartsBroken = true; heartsBroken = true;
return Hand()->Pass(card); return Hand()->Pass(card);
} }

60
Hearts/raster_font.cpp Normal file
View File

@@ -0,0 +1,60 @@
/* Copyright: (c) Kayne Ruse 2013
*
* 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, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*/
#include "raster_font.hpp"
#include <stdexcept>
/* It might be more efficient to render to a different surface (like an Image)
* rather than calling this function with all of it's '%' and '/'.
*/
void RasterFont::DrawStringTo(std::string s, SDL_Surface* const dest, Sint16 x, Sint16 y) {
if (!image.GetSurface()) {
throw(std::runtime_error("RasterFont not loaded"));
}
const Uint16 w = image.GetClipW();
const Uint16 h = image.GetClipH();
for (int i = 0; i < s.size(); i++) {
image.SetClipX(s[i] % 16 * w);
image.SetClipY(s[i] / 16 * h);
image.DrawTo(dest, x + i * w, y);
}
}
/* Note: This class can only take a raster font with 16*16 characters, and the
* indevidual characters must have the same dimensions. Overall this class is too
* restrictive; I suggest using a 3rd party library.
*/
SDL_Surface* RasterFont::LoadSurface(std::string fname) {
image.LoadSurface(fname);
image.SetClipW(image.GetSurface()->w/16);
image.SetClipH(image.GetSurface()->h/16);
return image.GetSurface();
}
SDL_Surface* RasterFont::SetSurface(SDL_Surface* p) {
image.SetSurface(p);
image.SetClipW(image.GetSurface()->w/16);
image.SetClipH(image.GetSurface()->h/16);
return image.GetSurface();
}

View File

@@ -1,7 +1,4 @@
/* File Name: image_manager.h /* Copyright: (c) Kayne Ruse 2013
* Author: Kayne Ruse
* Date (dd/mm/yyyy): 20/06/2011
* Copyright: (c) Kayne Ruse 2011, 2012
* *
* This software is provided 'as-is', without any express or implied * This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages * warranty. In no event will the authors be held liable for any damages
@@ -21,27 +18,32 @@
* *
* 3. This notice may not be removed or altered from any source * 3. This notice may not be removed or altered from any source
* distribution. * distribution.
*
* Description:
* The Image Manager creates, organises and cleans up the Images in the game.
* Part of the KAGE Game Engine.
*/ */
#ifndef KR_KAGE_IMAGEMANAGER_H_ #ifndef RASTERFONT_HPP_
#define KR_KAGE_IMAGEMANAGER_H_ #define RASTERFONT_HPP_
#include "named_manager.h" #include "image.hpp"
#include "image.h"
namespace KAGE { class RasterFont {
class ImageManager : public NamedManager<Image> {
public: public:
/* Public access members */ RasterFont() = default;
Image* Add(const char* name, const char* fileName, int x = 0, int y = 0, int w = 0, int h = 0); RasterFont(std::string fname) { LoadSurface(fname); }
Image* Add(const char* name, SDL_Surface* surface, int x = 0, int y = 0, int w = 0, int h = 0); RasterFont(SDL_Surface* p) { SetSurface(p); }
Image* Add(const char* name, Image* image); ~RasterFont() = default;
void DrawAll(SDL_Surface* dest, int camX = 0, int camY = 0); void DrawStringTo(std::string, SDL_Surface* const, Sint16 x, Sint16 y);
//Accessors and Mutators
SDL_Surface* LoadSurface(std::string);
SDL_Surface* SetSurface(SDL_Surface*);
SDL_Surface* GetSurface() const { return image.GetSurface(); }
void FreeSurface() { image.FreeSurface(); }
Uint16 GetCharW() const { return image.GetClipW(); }
Uint16 GetCharH() const { return image.GetClipH(); }
private:
Image image;
}; };
}
#endif #endif

View File

@@ -1,70 +0,0 @@
/* File Name: sound.cpp
* Author: Kayne Ruse
* Date (dd/mm/yyyy): 13/06/2011
* Copyright: (c) Kayne Ruse 2011, 2012
*
* 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, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* Description:
* The Sound class, a wrapper for Mix_Chunk and other sound functionality.
* Part of the KAGE Game Engine.
*/
#include <iostream>
#include "sound.h"
using namespace std;
using namespace KAGE;
//-------------------------
//Public access members
//-------------------------
Sound::Sound(const char* fName) {
chunk = Mix_LoadWAV(fName);
if (chunk == NULL) {
cout << "Error in Sound::Sound()" << endl;
cout << "Mix_LoadWAV() returned NULL" << endl;
cout << "fName: " << fName << endl;
}
}
Sound::~Sound() {
Mix_FreeChunk(chunk);
}
//-------------------------
//Accessors and mutators
//-------------------------
int Sound::Play(int channel,int loop) {
return Mix_PlayChannel(channel,chunk,loop);
}
int Sound::Volume(int volume) {
return Mix_VolumeChunk(chunk,volume);
}
//-------------------------
//Protected access members
//-------------------------
Mix_Chunk* Sound::GetMixChunk() {
return chunk;
}

View File

@@ -1,7 +1,7 @@
/* File Name: table.cpp /* File Name: table.cpp
* Author: Kayne Ruse * Author: Kayne Ruse
* Date (dd/mm/yyyy): 09/06/2011 * Date (dd/mm/yyyy): 21/01/2013
* Copyright: (c) Kayne Ruse 2011, 2012 * Copyright: (c) Kayne Ruse 2011, 2012, 2013
* *
* This software is provided 'as-is', without any express or implied * This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages * warranty. In no event will the authors be held liable for any damages
@@ -23,10 +23,12 @@
* distribution. * distribution.
* *
* Description: * Description:
* Designed for Project Hearts, 4th try. * Hold the cards in play, and determine the winner of a trick.
*/ */
#include "table.h" #include "table.h"
#include <stdexcept>
//------------------------- //-------------------------
//Public access members //Public access members
//------------------------- //-------------------------
@@ -49,30 +51,29 @@ Card* Table::Pass() {
void Table::Receive(Card* card, int position) { void Table::Receive(Card* card, int position) {
//position is the player's pos //position is the player's pos
if (position < 0 || position > 4) if (position < 0 || position > 3)
return; throw(std::invalid_argument("Unknown player index"));
cards[position] = card; cards[position] = card;
cards[position]->SetPos( cards[position]->SetPos(
cardPositions[position].x, cardPositions[position].x,
cardPositions[position].y cardPositions[position].y
); );
cards[position]->SetFace(Card::UP); cards[position]->SetFaceState(Card::UP);
} }
int Table::CalcWinner(int first) { int Table::CalcWinner(int first) {
if (first < 0 || first > 3) if (first < 0 || first > 3)
return -1; throw(std::invalid_argument("Unknown player index"));
int suit = cards[first]->Suit(); int suit = cards[first]->GetSuit();
int winner = -1; int winner = -1;
int highest = -1; int highest = -1;
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
if (cards[i]->Suit() == suit && if (cards[i]->GetSuit() == suit && cards[i]->GetRank() > highest)
cards[i]->Rank() > highest)
{ {
highest = cards[i]->Rank(); highest = cards[i]->GetRank();
winner = i; winner = i;
} }
} }
@@ -82,8 +83,8 @@ int Table::CalcWinner(int first) {
int Table::GetLeadingSuit(int first) { int Table::GetLeadingSuit(int first) {
if (cards[first] == NULL) if (cards[first] == NULL)
return -1; return -1; //this means "No cards yet..." -?
return cards[first]->Suit(); return cards[first]->GetSuit();
} }
//------------------------- //-------------------------
@@ -107,5 +108,5 @@ void Table::Draw(SDL_Surface* dest, int first) {
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
if (cards[(i + first) % 4] != NULL) if (cards[(i + first) % 4] != NULL)
cards[(i + first) % 4]->Draw(dest); cards[(i + first) % 4]->DrawTo(dest);
} }

View File

@@ -1,7 +1,7 @@
/* File Name: table.h /* File Name: table.h
* Author: Kayne Ruse * Author: Kayne Ruse
* Date (dd/mm/yyyy): 09/06/2011 * Date (dd/mm/yyyy): 21/01/2013
* Copyright: (c) Kayne Ruse 2011, 2012 * Copyright: (c) Kayne Ruse 2011, 2012, 2013
* *
* This software is provided 'as-is', without any express or implied * This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages * warranty. In no event will the authors be held liable for any damages
@@ -23,11 +23,11 @@
* distribution. * distribution.
* *
* Description: * Description:
* Designed for Project Hearts, 4th try. * Hold the cards in play, and determine the winner of a trick.
*/ */
#ifndef KR_TABLE_H_ #ifndef KR_TABLE_H_
#define KR_TABLE_H_ #define KR_TABLE_H_
#include "SDL.h"
#include "card_list.h" #include "card_list.h"
class Table { class Table {

View File

@@ -1,15 +1,16 @@
* Try to keep the project as stable as possible. * Try to keep the project as stable as possible.
* Use a separate development branch where necessary * Use a separate development branch where necessary
* Don't forget to search for "TODO" tags in the code
* Remove NamedManager as soon as possible * Remove NamedManager as soon as possible
* Remove unnecessary KAGE modules * Remove unnecessary KAGE modules
* Rearrange the project hierarchy > Rearrange the project hierarchy
* Breakdown and analyse the structure * Breakdown and analyse the structure
* Upgrade to the current Codebase where possible * Upgrade to the current Codebase where possible
* Remedy Card's graphical system > Remedy Card's graphical system
* Use the current Image class in Card & Deck > Use the current Image class in Card & Deck
* Add in graphical buttons and onscreen text for user friendlyness * Add in graphical buttons and onscreen text for user friendlyness
* Research SDL_mixer, to fully understand the audio system * Research SDL_mixer, to fully understand the audio system
@@ -20,3 +21,5 @@
This system seems to be split between the three player classes This system seems to be split between the three player classes
I could use a unified highlighting system for both swapping and playing a card I could use a unified highlighting system for both swapping and playing a card
~~~~~

BIN
Notes/screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@@ -1,21 +1,17 @@
# Project Hearts version 1.0, 22nd June 2011 # Project Hearts version 1.1, 6th September 2013
## Introduction ## Introduction
This project is over 1 1/2 years old, so it doesn't reflect my current programming skills. Regardless, it's a pretty good demonstration of my development. From the KAGE engine, you can see what my thought processes at the time were, and you can probably guess that this evolved into my [Codebase](https://github.com/Ratstail91/Codebase). This has a sound system, and some aspects are different, but it's not a terrible start. I<>ve also included all of the unused modules including NetworkManager, which aren<65>t used here, but are simply part of KAGE. I've added a few features that I wanted, mostly to show off that I can complete a set task. Hopefully the program will be sufficient proof, as long as job interviewers don't look at the code.
I'd say that my biggest problem when I was learning was my overreliance on inheritance. You can see this from Card being descended from Image, a common habit in my old code. Also, the presence of NamedManager, which was essentially a wrapper for std::map, and was used to create several different Manager classes isn<73>t something I<>d do today. ![screenshot](Notes/screenshot.png)
Finally, my biggest mistake I believe, was that I made the KAGE engine closed source. This is a bad idea, since having code visible shows off what you can do. Whether it<69>s to a potential employer, or to someone critiquing your code, it<69>s always a good idea to show what you can do. That<61>s exactly why I<>m uploading this old project. Maybe if I had someone to guide me on the engine<6E>s design at the time, I<>d have a radically different Codebase and coding style today.
I don<6F>t consider this project complete, since it<69>s still missing a score display and a card passing button, but the scores are shown in the console window (stdout) and the F1 button compensates for a lack of graphical buttons. I<>d like to remake this, using the existing game logic to rely on my current Codebase version. If I do, I<>ll release the modified version under the zlib license.
## Instructions ## Instructions
Drop the "rsc" folder into the same directory as the executable Drop the "rsc" folder into the same directory as the executable
To select a card, click on it To select a card, click on it
To pass three cards at the start of the round, select them and press F1 To pass three cards at the start of the round, select them and press the pass button
To speed up the wait after a round, press F1 Try to keep your score as low as possible by avoiding the hearts cards, and the queen of spades
## Copyright ## Copyright
@@ -33,7 +29,5 @@ Permission is granted to anyone to use this software for any purpose, including
## Contact information ## Contact information
ratstail91@yahoo.com.au krgamestudios@gmail.com
http://kr-studios.tumblr.com/ 1.0 Build: https://www.dropbox.com/s/gqo2qqj6v1pejyq/Hearts%20by%20Kayne%20Ruse.rar?dl=1
http://www.facebook.com/krgamestudios
Oldest known version: https://dl.dropbox.com/u/46669050/Hearts%20by%20Kayne%20Ruse.rar

33
makefile Normal file
View File

@@ -0,0 +1,33 @@
#for use on Windows:
#MKDIR=mkdir
#RM=del /y
CXXFLAGS+=-static-libgcc -static-libstdc++
CFLAGS+=-static-libgcc
export
OUTDIR=out
all: $(OUTDIR)
$(MAKE) -C Hearts
debug: export CXXFLAGS+=-g
debug: clean all
$(OUTDIR):
mkdir $(OUTDIR)
clean:
ifeq ($(OS),Windows_NT)
del /S /Q *.o *.a *.exe $(OUTDIR)\*
rmdir /S /Q $(OUTDIR)
else ifeq ($(shell uname), Linux)
find . -type f -name '*.o' -exec rm -f -r -v {} \;
find . -type f -name '*.a' -exec rm -f -r -v {} \;
rm $(OUTDIR)/* -f
find . -empty -type d -delete
endif
rebuild: clean all

BIN
rsc/button.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

BIN
rsc/pk_white_8.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB