Skip to content

Commit bb57eca

Browse files
committed
[CHG] The Point class as moved to types.h
git-svn-id: https://wii-tac-toe.googlecode.com/svn/tags/0.6@41 bba1cac1-252d-79fd-420d-80adb1f9fa09
1 parent 816e7f8 commit bb57eca

File tree

10 files changed

+97
-84
lines changed

10 files changed

+97
-84
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ include $(DEVKITPPC)/wii_rules
1515
# SOURCES is a list of directories containing source code
1616
# INCLUDES is a list of directories containing extra header files
1717
#---------------------------------------------------------------------------------
18-
TARGET := $(notdir $(CURDIR))
18+
TARGET := Wii-Tac-Toe
1919
BUILD := build
2020
SOURCES := source source/grrlib source/libpng/pngu
2121
DATA := data

source/game.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,13 @@ void Game::GameScreen(bool CopyScreen)
231231

232232
// Draw grid content
233233
Symbol *Sign = new Symbol;
234-
for(int x = 0; x < 3; x++)
234+
u8 x, y;
235+
for(x = 0; x < 3; x++)
235236
{
236-
for(int y = 0; y < 3; y++)
237+
for(y = 0; y < 3; y++)
237238
{
238239
Sign->SetPlayer(GameGrid->GetPlayerAtPos(x, y));
239-
Sign->SetLeft(Table[x][y].GetX());
240-
Sign->SetTop(Table[x][y].GetY());
240+
Sign->SetLocation(Table[x][y].GetX(), Table[x][y].GetY());
241241
Sign->Paint();
242242
}
243243
}

source/game.h

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "cursor.h"
99
#include "player.h"
1010
#include "language.h"
11+
#include "types.h"
1112

1213
#define TEXT_SIZE 100
1314

@@ -77,48 +78,5 @@ class Game
7778
u8 AIThinkLoop;
7879
gameMode GameMode;
7980
};
80-
81-
/**
82-
* Class used to defines a pixel location onscreen.
83-
* @author Crayon
84-
*/
85-
class Point
86-
{
87-
private:
88-
u16 x, y;
89-
public:
90-
/**
91-
* Constructor for the Point class.
92-
*/
93-
Point(u16 x, u16 y)
94-
{
95-
this->x = x;
96-
this->y = y;
97-
}
98-
/**
99-
* Get the x position.
100-
*/
101-
u16 GetX()
102-
{
103-
return x;
104-
}
105-
/**
106-
* Get the y position.
107-
*/
108-
u16 GetY()
109-
{
110-
return y;
111-
}
112-
/**
113-
* Set the new position.
114-
* @param[in] x Specifies the x-coordinate.
115-
* @param[in] y Specifies the y-coordinate.
116-
*/
117-
void setLocation(u16 x, u16 y)
118-
{
119-
this->x = x;
120-
this->y = y;
121-
}
122-
};
12381
//---------------------------------------------------------------------------
12482
#endif

source/grid.cpp

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,12 @@ bool Grid::SetPlayer(u8 Player, u8 X, u8 Y)
7373
void Grid::SetPlayerAI(u8 Player)
7474
{
7575
u8 TestBoard[3][3];
76+
u8 x, y;
7677

7778
// Test win
78-
for(int x = 0; x < 3; x++)
79+
for(x = 0; x < 3; x++)
7980
{
80-
for(int y = 0; y < 3; y++)
81+
for(y = 0; y < 3; y++)
8182
{
8283
memcpy(TestBoard, Board, sizeof(TestBoard));
8384
if(TestBoard[x][y] == ' ')
@@ -94,9 +95,9 @@ void Grid::SetPlayerAI(u8 Player)
9495

9596
// Test block
9697
u8 Opponent = (Player == 'X') ? 'O' : 'X';
97-
for(int x = 0; x < 3; x++)
98+
for(x = 0; x < 3; x++)
9899
{
99-
for(int y = 0; y < 3; y++)
100+
for(y = 0; y < 3; y++)
100101
{
101102
memcpy(TestBoard, Board, sizeof(TestBoard));
102103
if(TestBoard[x][y] == ' ')
@@ -144,24 +145,9 @@ u8 Grid::GetPlayerAtPos(u8 X, u8 Y)
144145
*/
145146
void Grid::Clear()
146147
{
147-
for(int x = 0; x < 3; x++)
148-
{
149-
for(int y = 0; y < 3; y++)
150-
{
151-
Board[x][y] = ' ';
152-
}
153-
}
148+
memset(Board, ' ', sizeof(Board));
154149
}
155150

156-
/**
157-
* Return the complete grid.
158-
*/
159-
/*
160-
u8[][] Grid::GetGrid()
161-
{
162-
return Board;
163-
}
164-
*/
165151
/**
166152
* Return the winner.
167153
* @return Winning player.
@@ -237,9 +223,10 @@ bool Grid::IsPlayerWinning(u8 Player)
237223
*/
238224
bool Grid::IsFilled()
239225
{
240-
for(int x = 0; x < 3; x++)
226+
u8 x, y;
227+
for(x = 0; x < 3; x++)
241228
{
242-
for(int y = 0; y < 3; y++)
229+
for(y = 0; y < 3; y++)
243230
{
244231
if(Board[x][y] == ' ')
245232
return false;

source/grid.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class Grid
2020
void SetPlayerRandom(u8);
2121
void SetPlayerAI(u8);
2222
u8 GetPlayerAtPos(u8, u8);
23-
//u8[][] GetGrid();
2423
u8 GetWinner();
2524
void Clear();
2625
bool IsFilled();

source/object.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,19 @@ void Object::SetTop(float Top)
5959
this->Top = Top;
6060
}
6161

62+
/**
63+
* Set the left and top position of the object.
64+
* @param[in] Left Left in pixel.
65+
* @param[in] Top Top in pixel.
66+
* @see SetLeft()
67+
* @see SetTop()
68+
*/
69+
void Object::SetLocation(float Left, float Top)
70+
{
71+
this->Left = Left;
72+
this->Top = Top;
73+
}
74+
6275
/**
6376
* Get the width of the object.
6477
* @see SetWidth()
@@ -132,13 +145,6 @@ void Object::SetVisible(bool Visible)
132145
this->Visible = Visible;
133146
}
134147

135-
/**
136-
* Draw an image on screen.
137-
*/
138-
void Object::Paint()
139-
{
140-
}
141-
142148
/**
143149
* Check if a position is inside the object.
144150
* @param[in] x X position in pixel.

source/object.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class Object
2424
bool IsVisible();
2525
void SetLeft(float);
2626
void SetTop(float);
27+
void SetLocation(float, float);
2728
void SetWidth(unsigned int);
2829
void SetHeight(unsigned int);
2930
void SetSize(unsigned int, unsigned int);
@@ -32,7 +33,7 @@ class Object
3233
void SetVisible(bool);
3334
bool IsInside(float, float);
3435
protected:
35-
virtual void Paint();
36+
virtual void Paint() = 0; /**< Draw an image on screen. */
3637

3738
float Left; /**< Specifies the x-coordinate of the upper-left corner of the object. */
3839
float Top; /**< Specifies the y-coordinate of the upper-left corner of the object. */

source/symbol.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111
Symbol::Symbol() : Object()
1212
{
13-
this->Player = 'X';
13+
Player = 'X';
1414

1515
ImgO = GRRLIB_LoadTexture(o);
1616
ImgX = GRRLIB_LoadTexture(x);
@@ -45,9 +45,9 @@ void Symbol::Paint()
4545

4646
/**
4747
* Set the current player to draw on the screen.
48-
* @param[in] Player Player sign, either X or O.
48+
* @param[in] APlayer Player sign, either X or O.
4949
*/
50-
void Symbol::SetPlayer(unsigned char Player)
50+
void Symbol::SetPlayer(unsigned char APlayer)
5151
{
52-
this->Player = Player;
52+
Player = APlayer;
5353
}

source/types.h

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//---------------------------------------------------------------------------
2+
#ifndef TypesH
3+
#define TypesH
4+
//---------------------------------------------------------------------------
5+
6+
#include <gccore.h>
7+
8+
/**
9+
* Class used to defines a pixel location onscreen.
10+
* @author Crayon
11+
*/
12+
class Point
13+
{
14+
private:
15+
u16 x, y;
16+
public:
17+
/**
18+
* Constructor for the Point class.
19+
* Initializes a point at the origin (0, 0) of the coordinate space.
20+
*/
21+
Point()
22+
{
23+
this->x = 0;
24+
this->y = 0;
25+
}
26+
/**
27+
* Constructor for the Point class.
28+
* @param[in] x Specifies the x-coordinate.
29+
* @param[in] y Specifies the y-coordinate.
30+
*/
31+
Point(u16 x, u16 y)
32+
{
33+
this->x = x;
34+
this->y = y;
35+
}
36+
/**
37+
* Get the x position.
38+
*/
39+
u16 GetX()
40+
{
41+
return x;
42+
}
43+
/**
44+
* Get the y position.
45+
*/
46+
u16 GetY()
47+
{
48+
return y;
49+
}
50+
/**
51+
* Set the new position.
52+
* @param[in] x Specifies the x-coordinate.
53+
* @param[in] y Specifies the y-coordinate.
54+
*/
55+
void SetLocation(u16 x, u16 y)
56+
{
57+
this->x = x;
58+
this->y = y;
59+
}
60+
};
61+
//---------------------------------------------------------------------------
62+
#endif

wii-tac-toe.pnproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<Project name="Wii-Tac-Toe"><MagicFolder excludeFolders="CVS;.svn" filter="*.c;*.cpp;*.h" name="source" path="source\"><MagicFolder excludeFolders="CVS;.svn" filter="*.c;*.cpp;*.h" name="grrlib" path="grrlib\"><File path="GRRLIB.c"></File><File path="GRRLIB.h"></File></MagicFolder><MagicFolder excludeFolders="CVS;.svn" filter="*.c;*.cpp;*.h" name="libjpeg" path="libjpeg\"><File path="jconfig.h"></File><File path="jmorecfg.h"></File><File path="jpeglib.h"></File><File path="jpgogc.h"></File></MagicFolder><MagicFolder excludeFolders="CVS;.svn" filter="*.c;*.cpp;*.h" name="libpng" path="libpng\"><MagicFolder excludeFolders="CVS;.svn" filter="*.c;*.cpp;*.h" name="pngu" path="pngu\"><File path="pngu.c"></File><File path="pngu.h"></File></MagicFolder><File path="png.h"></File><File path="pngconf.h"></File></MagicFolder><MagicFolder excludeFolders="CVS;.svn" filter="*.c;*.cpp;*.h" name="mxml" path="mxml\"><File path="mxml.h"></File></MagicFolder><File path="button.cpp"></File><File path="button.h"></File><File path="cursor.cpp"></File><File path="cursor.h"></File><File path="game.cpp"></File><File path="game.h"></File><File path="grid.cpp"></File><File path="grid.h"></File><File path="language.cpp"></File><File path="language.h"></File><File path="main.cpp"></File><File path="main.h"></File><File path="object.cpp"></File><File path="object.h"></File><File path="player.cpp"></File><File path="player.h"></File><File path="symbol.cpp"></File><File path="symbol.h"></File><File path="tools.cpp"></File><File path="tools.h"></File></MagicFolder><MagicFolder excludeFolders="CVS;.svn" filter="*.h" name="include" path="include\"></MagicFolder><Folder name="fonts"></Folder><Folder name="gfx"></Folder><File path="Makefile"></File></Project>
1+
<Project name="Wii-Tac-Toe"><MagicFolder excludeFolders="CVS;.svn" filter="*.c;*.cpp;*.h" name="source" path="source\"><MagicFolder excludeFolders="CVS;.svn" filter="*.c;*.cpp;*.h" name="grrlib" path="grrlib\"><File path="GRRLIB.c"></File><File path="GRRLIB.h"></File></MagicFolder><MagicFolder excludeFolders="CVS;.svn" filter="*.c;*.cpp;*.h" name="libjpeg" path="libjpeg\"><File path="jconfig.h"></File><File path="jmorecfg.h"></File><File path="jpeglib.h"></File><File path="jpgogc.h"></File></MagicFolder><MagicFolder excludeFolders="CVS;.svn" filter="*.c;*.cpp;*.h" name="libpng" path="libpng\"><MagicFolder excludeFolders="CVS;.svn" filter="*.c;*.cpp;*.h" name="pngu" path="pngu\"><File path="pngu.c"></File><File path="pngu.h"></File></MagicFolder><File path="png.h"></File><File path="pngconf.h"></File></MagicFolder><MagicFolder excludeFolders="CVS;.svn" filter="*.c;*.cpp;*.h" name="mxml" path="mxml\"><File path="mxml.h"></File></MagicFolder><File path="button.cpp"></File><File path="button.h"></File><File path="cursor.cpp"></File><File path="cursor.h"></File><File path="game.cpp"></File><File path="game.h"></File><File path="grid.cpp"></File><File path="grid.h"></File><File path="language.cpp"></File><File path="language.h"></File><File path="main.cpp"></File><File path="main.h"></File><File path="object.cpp"></File><File path="object.h"></File><File path="player.cpp"></File><File path="player.h"></File><File path="symbol.cpp"></File><File path="symbol.h"></File><File path="tools.cpp"></File><File path="tools.h"></File><File path="types.h"></File></MagicFolder><MagicFolder excludeFolders="CVS;.svn" filter="*.h" name="include" path="include\"></MagicFolder><Folder name="fonts"></Folder><Folder name="gfx"></Folder><File path="Makefile"></File></Project>

0 commit comments

Comments
 (0)