1 Replies - 977 Views - Last Post: 22 October 2014 - 04:03 PM Rate Topic: -----

#1 nvnjolly   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 22-October 14

C++ CHECKERS game cant get the object to move :C

Posted 22 October 2014 - 02:55 PM

hi guys so i made a checkers game. got all the board set up and everything. but i cant get the object to move. i tried different stuff but cant get it to move.

this is my code;

#include "ccc_win.h"

void initNewgame(int x, int y, int r, int g, int b, PenWidth pen1, PenColour blackPen)
{
	
	
	BrushColour sBrush = BrushColour(r, g, B)/>;
	Point p(6.3, 3.5);
	Point p1(x - 2, y + 1);
	Point p2(x + 2, y - 1);
	Rectangle square(p1, p2);
	string s = "New Game";
	Message newGame(p, s);
	cwin << pen1 << blackPen << sBrush << square << newGame;

}

void initExit(int x, int y, int r, int g, int b, PenWidth pen1, PenColour blackPen)
{
	BrushColour sBrush = BrushColour(r, g, B)/>;
	Point p(15.3, 3.5);
	Point p1(x - 2, y + 1);
	Point p2(x + 2, y - 1);
	Rectangle square(p1, p2);
	string s = "Exit Game";
	Message exit(p, s);
	cwin << pen1 << blackPen << sBrush << square << exit;
}
void initSquare(int x, int y, int r, int g, int b, PenWidth pen1, PenColour blackPen)
{
	BrushColour sBrush = BrushColour(r, g, B)/>;
	Point p(x, y);
	Point p1(x - 1, y - 1);
	Point p2(x + 1, y + 1);
	Rectangle square(p1, p2);
	cwin << pen1 << blackPen << sBrush << square;
}

void initCircle(int x, int y, int r, int g, int b, PenWidth pen1, PenColour blackPen)
{
	BrushColour sBrush = BrushColour(r, g, B)/>;
	Point p(x, y);
	Circle smallCircle(p, 0.8);
	cwin << pen1 << blackPen << sBrush << smallCircle;
}

int ccc_win_main()
{
	cwin.coord(0, 24, 24, 0);
	PenWidth pen1 = PenWidth(1);
	PenColour blackPen = PenColour(0, 0, 0);
	bool isDark = false;
	initExit(16, 3, 240, 230, 70, pen1, blackPen);
	initNewgame(8, 3, 240, 230, 70, pen1, blackPen);
	for (int x = 5; x < 20; x = x + 2)
	{
		if (isDark == true)
		{
			isDark = false;
		}
		else
			isDark = true;
		for (int y = 7; y < 22; y = y + 2)
		{
			if (isDark == true)
			{
				initSquare(x, y, 55, 180, 15, pen1, PenColour(0, 0, 0));
				isDark = false;
			}
			else{
				initSquare(x, y, 240, 230, 70, pen1, PenColour(0, 0, 0));
				isDark = true;
			}
		}
	}

	for (int x = 5; x < 20; x = x + 4)
	{
		for (int y = 7; y < 12; y = y + 4)
		{
			initCircle(x, y, 255, 0, 0, pen1, blackPen);
		}
	}
	for (int x = 7; x < 20; x = x + 4)
	{
		int y = 9;
		initCircle(x, y, 255, 0, 0, pen1, blackPen);
	}


	for (int x = 7; x < 20; x = x + 4)
	{
		for (int y = 17; y < 22; y = y + 4)
		{
			initCircle(x, y, 255, 255, 255, pen1, blackPen);
		}
	}
	for (int x = 5; x < 20; x = x + 4)
	{
		int y = 19;
		initCircle(x, y, 255, 255, 255, pen1, blackPen);
	}


	Point p = cwin.get_mouse("check");
	double x = p.get_x();
	double y = p.get_y();

	if (x >= 8.3 && x <= 4.3 &&
		y >= 4.5 && y <= 2.5)
	{
		return 1;
	}
	return 0;
}





can anyone help me how to solve this. or give me some tips?

Is This A Good Question/Topic? 0
  • +

Replies To: C++ CHECKERS game cant get the object to move :C

#2 infernorthor   User is offline

  • D.I.C Lover

Reputation: 362
  • View blog
  • Posts: 1,718
  • Joined: 07-February 14

Re: C++ CHECKERS game cant get the object to move :C

Posted 22 October 2014 - 04:03 PM

Well you don't seem to have any mechanics.
You should make more functions like a void drawBoard(); function just to tidy start up.

You don't seem to be storing where the pieces are? So how will you know if you click a piece or jump another piece?

Let's make it simple though. Simply draw the board. Only add one piece, and try to get it so you can move it every where. I would suggest to make a Piece class.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1