Breach

Check-in [51b5178f61]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:cleaned up a bit of the game logic, namely checking for win/loss conditions and loading initial data for GameObjects (which isnt complete yet)
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:51b5178f61b5121921ffb90dc6204d3f2c0ca004
User & Date: donnyjward@gmail.com 2011-09-10 06:55:15
Context
2012-11-02
04:45
Added Photoshop 7 templates. Leaf check-in: 0550bf85e8 user: Donny tags: trunk
2011-09-10
06:55
cleaned up a bit of the game logic, namely checking for win/loss conditions and loading initial data for GameObjects (which isnt complete yet) check-in: 51b5178f61 user: donnyjward@gmail.com tags: trunk
04:39
colors can now be assigned to blocks in edit mode using right click! right clicking a block will cycle through all the available colors check-in: 06e2db82a3 user: donnyjward@gmail.com tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to breach.cpp.

59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
extern const int PADDLE_ARCERROR = 20;

extern const int MAX_GAMEOBJECTS = 50;

extern const int MIN_BLOCKLENGTH = 50;
extern const int OUTLINE_THICKNESS = 3;

extern const int MAX_LIVES = 500;

extern const int PI = 3.14159265;

//Aircraft radius
extern const int AIRCRAFT_RADIUS = 10;









|







59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
extern const int PADDLE_ARCERROR = 20;

extern const int MAX_GAMEOBJECTS = 50;

extern const int MIN_BLOCKLENGTH = 50;
extern const int OUTLINE_THICKNESS = 3;

extern const int MAX_LIVES = 3;

extern const int PI = 3.14159265;

//Aircraft radius
extern const int AIRCRAFT_RADIUS = 10;


Changes to g_gameobject.cpp.

54
55
56
57
58
59
60
61
62
63
64


65
66
67
68
69
70
71
..
78
79
80
81
82
83
84



85
86
87
88
89
90
91
			break;
		else
			delete ObjectsList[i];
	}
	
}

void GameObjects::loadData()
{
	GamePaddle = new Paddle();
	


	//addObject( new Aircraft(400, 300, 7, 2) );
	//addObject( new Aircraft(30, 30, 3, 0) );
	//addObject( new Aircraft(500, 200, 1, 8) );
//		Block(int startX, int startY, int width, int height, int hp, bool soft, color_t c);
	addObject( new Block(0, 0, 50, 100, 100, true, COLOR_RED) );
	addObject( new Block(300, 200, 50, 50, 100, true, COLOR_BLUE) );
	addObject( new Block(400, 500, 300, 20, 100, false, COLOR_GREEN) );
................................................................................
//		Block(int startX, int startY, int width, int height, int hp, bool soft, color_t c);
	ObjectsList[3] = new Block(0, 0, 50, 100, 100, true, COLOR_RED);
	ObjectsList[4] = new Block(300, 200, 50, 50, 100, true, COLOR_BLUE);
	ObjectsList[5] = new Block(600, 100, 80, 30, 100, true, COLOR_YELLOW);
	ObjectsSize = 6;
*/	
	//FIXME: add code here to load game objects from bin file



}

void GameObjects::addObject(GameObject * addMe)
{
	if (ObjectsSize < MAX_GAMEOBJECTS)
	{
		ObjectsList[ObjectsSize] = addMe;







|



>
>







 







>
>
>







54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
..
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
			break;
		else
			delete ObjectsList[i];
	}
	
}

void GameObjects::loadData(string mapname)
{
	GamePaddle = new Paddle();
	
	if (mapname != "")
	{
	//addObject( new Aircraft(400, 300, 7, 2) );
	//addObject( new Aircraft(30, 30, 3, 0) );
	//addObject( new Aircraft(500, 200, 1, 8) );
//		Block(int startX, int startY, int width, int height, int hp, bool soft, color_t c);
	addObject( new Block(0, 0, 50, 100, 100, true, COLOR_RED) );
	addObject( new Block(300, 200, 50, 50, 100, true, COLOR_BLUE) );
	addObject( new Block(400, 500, 300, 20, 100, false, COLOR_GREEN) );
................................................................................
//		Block(int startX, int startY, int width, int height, int hp, bool soft, color_t c);
	ObjectsList[3] = new Block(0, 0, 50, 100, 100, true, COLOR_RED);
	ObjectsList[4] = new Block(300, 200, 50, 50, 100, true, COLOR_BLUE);
	ObjectsList[5] = new Block(600, 100, 80, 30, 100, true, COLOR_YELLOW);
	ObjectsSize = 6;
*/	
	//FIXME: add code here to load game objects from bin file
	}
	else
		addObject( new Block(400, 500, 300, 20, 100, true, COLOR_GREEN) );
}

void GameObjects::addObject(GameObject * addMe)
{
	if (ObjectsSize < MAX_GAMEOBJECTS)
	{
		ObjectsList[ObjectsSize] = addMe;

Changes to g_gameobject.h.

1
2
3
4
5



6
7
8
9
10
11
12
...
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
#ifndef __G_GAMEOBJECT_H__
#define __G_GAMEOBJECT_H__

#include "defs.h"
#include "r_graphics.h"




//FIXME: if i change the core gameplay to consist of
//	just deflecting incoming balls, i may have to
//	restructure the gameobject class and its subclasses
//	since there will be more then 1 type of "ball",
//	and it might be better to have global SDL_Surface *'s
//	that all of the different balls share, because they
................................................................................
		
		//draws all the game objects
		void Draw();
		
		Paddle * getPaddle();
		void initData();
		void deleteData();
		void loadData();
		void addObject(GameObject * addMe);
		int findObject(GameObject * findMe);
		void removeObject(GameObject * removeMe);
		GameObject * returnObject(int index);
		
		int getObjectsSize();
		





>
>
>







 







|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
...
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
#ifndef __G_GAMEOBJECT_H__
#define __G_GAMEOBJECT_H__

#include "defs.h"
#include "r_graphics.h"
#include <string>

using namespace std;

//FIXME: if i change the core gameplay to consist of
//	just deflecting incoming balls, i may have to
//	restructure the gameobject class and its subclasses
//	since there will be more then 1 type of "ball",
//	and it might be better to have global SDL_Surface *'s
//	that all of the different balls share, because they
................................................................................
		
		//draws all the game objects
		void Draw();
		
		Paddle * getPaddle();
		void initData();
		void deleteData();
		void loadData(string mapname = "");
		void addObject(GameObject * addMe);
		int findObject(GameObject * findMe);
		void removeObject(GameObject * removeMe);
		GameObject * returnObject(int index);
		
		int getObjectsSize();
		

Changes to s_statemachine.cpp.

499
500
501
502
503
504
505
506






507

508
509
510
511
512
513
514
515
...
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
...
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
	//thePaddle->TryMove(mouseX, mouseY);
	//theBall->TryMove(mouseX, mouseY);
	
	//update all the game objects
	Objects.Update();

	//check for win/loss conditions
	






	//check if all lives ran out

	if (!Objects.getNumLivesLeft())
	{
		cout << fileID << "game over\n";
		s_setNextState(STATE_EXIT);
	}
}

void StatePlaying::Render()
................................................................................
	Block * blk = NULL;
	int c;

	//bool goodBox = true;
	goodBox = true;
	//warp mouse back to center but dont register
	//	it as an event
	SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE);
	//SDL_WarpMouse(400,300);
	SDL_EventState(SDL_MOUSEMOTION, SDL_ENABLE);
		
	//move paddle to new position based on gathered mouse movement
	//thePaddle->TryMove(mouseX, mouseY);
	//theBall->TryMove(mouseX, mouseY);
	
	//update all the game objects
	Objects.Update();

	//check for win/loss conditions



	//if dragging a box, position the outline
	if (leftClickHeld)
	{
		boxEndX = Objects.mouseX;
		boxEndY = Objects.mouseY;
................................................................................
			}
		}
		else
		{
			//cout << fileID << "didnt right click on a block!\n";
		}
	}

	//check if all lives ran out
	if (!Objects.getNumLivesLeft())
	{
		cout << fileID << "game over\n";
		s_setNextState(STATE_EXIT);
	}
}

void StateEditing::Render()
{
	//blit background image if applicable
	if (background != NULL)
	{
		if ( !r_blitSurface(0, 0, background, screen) && DEBUG )
			cout << fileID << "blit background image failed\n";
	}
	else
		SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 255, 255, 255));
		
	//blit the paddle with correct facing
	//thePaddle->Draw();
	//theBall->Draw();
	
	//draw all the game objects
	Objects.Draw();

	//draw the new box outline if applicable
	if (leftClickHeld)
	{







|
>
>
>
>
>
>
|
>
|







 







|

|








<
<







 







<
<
<
<
<
<
<












<
<
<
<







499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
...
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670


671
672
673
674
675
676
677
...
754
755
756
757
758
759
760







761
762
763
764
765
766
767
768
769
770
771
772




773
774
775
776
777
778
779
	//thePaddle->TryMove(mouseX, mouseY);
	//theBall->TryMove(mouseX, mouseY);
	
	//update all the game objects
	Objects.Update();

	//check for win/loss conditions

	//check for all soft blocks gone
	if (!Objects.getNumBlocks())
	{
		cout << fileID << "You win!\n";	
		s_setNextState(STATE_EXIT);
	}
	//check if all lives ran out and you didnt take
	//	out the last block with your last ball
	else if (!Objects.getNumLivesLeft())
	{
		cout << fileID << "game over\n";
		s_setNextState(STATE_EXIT);
	}
}

void StatePlaying::Render()
................................................................................
	Block * blk = NULL;
	int c;

	//bool goodBox = true;
	goodBox = true;
	//warp mouse back to center but dont register
	//	it as an event
	//SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE);
	//SDL_WarpMouse(400,300);
	//SDL_EventState(SDL_MOUSEMOTION, SDL_ENABLE);
		
	//move paddle to new position based on gathered mouse movement
	//thePaddle->TryMove(mouseX, mouseY);
	//theBall->TryMove(mouseX, mouseY);
	
	//update all the game objects
	Objects.Update();





	//if dragging a box, position the outline
	if (leftClickHeld)
	{
		boxEndX = Objects.mouseX;
		boxEndY = Objects.mouseY;
................................................................................
			}
		}
		else
		{
			//cout << fileID << "didnt right click on a block!\n";
		}
	}







}

void StateEditing::Render()
{
	//blit background image if applicable
	if (background != NULL)
	{
		if ( !r_blitSurface(0, 0, background, screen) && DEBUG )
			cout << fileID << "blit background image failed\n";
	}
	else
		SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 255, 255, 255));




	
	//draw all the game objects
	Objects.Draw();

	//draw the new box outline if applicable
	if (leftClickHeld)
	{