kutuup 25 Junior Poster in Training

So I'm working on a Windows Phone app using XNA and I'm at my wit's end with it.

Here is the code:

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Input.Touch;
using Microsoft.Xna.Framework.Media;

namespace WindowsPhoneGame1
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        int[,] map = new int[10,10];
        int[,] blankMap = new int[10, 10];
        int[] validmove1 = new int[2];
        int[] validmove2 = new int[2];
        int[] validmove3 = new int[2];
        int[] validmove4 = new int[2];
        int[] lastmove = new int[2];

        int touchx;
        int touchy;

        int moves;

        string outputString;

        Vector2 drawbuffer;
        Vector2 FontPos1;

        Texture2D blank;
        Texture2D cross;
        Texture2D nought;
        Texture2D wall;
        SpriteFont Font1;

            void resetMap()
    {
        Array.Copy(blankMap,map,100);
        //memcpy(map,resetmap,sizeof map);
        //PlaySound(L"restart.wav", NULL, SND_ASYNC | SND_FILENAME);
    }

            bool checkwin()
        {
            int numnought = 0;

            for (int countline = 0; countline <= 9; countline++)
            {
                for (int count = 0; count <= 9; count++)
                {
                    if (map[countline,count] == 1)
                    {
                        numnought++;
                    }
                }
            }
            if (numnought >= 1)
            {
                return false;
            }
            else
            {
                return true;
            }
        }

            bool canmove()
    {

        int movey = lastmove[0];
        int movex = lastmove[1];
        int[] checkblank = new int[2];
        checkblank[0] = 0;
        checkblank[1] = 0;
        int possmoves = 0;

        if(map[movey+1,movex] == 1)
        {
            possmoves ++;
            validmove1[0] = movey+1;
            validmove1[1] = movex;
        }
        else if(map[movey+1,movex] == 0 && map[movey+2,movex] == 1)
        {
                possmoves ++;
                validmove1[0] = movey+2;
                validmove1[1] = movex;
        }
        else if(map[movey+1,movex] == 2)
        {
            checkblank[0] = …
kutuup 25 Junior Poster in Training

Did you rebuild all (including all dependencies) in release mode?

Nope, and that was the problem! I didn't add the dependencies in release mode. Sorry, rookie mistake I suppose!

Thanks!

kutuup 25 Junior Poster in Training

Hello,

I am putting together a shoddy game for a 48 hour game contest and I have a problem.

When I run the program from within VS2008 (by clicking the start debugging button) the program runs fine. I'm doing this in release mode btw.
However, If I try and run the program using the .exe generated in the "release" folder of the project. The program starts, opens the display window, them promptly crashes with a "this program has stopped working" message. The display window opens, so the program at least begins to run, then just crashes for some reason.

I can't for the life of me figure out why that might be and the error message offers sweet FA in terms of advice as to what might be wrong. This has never happened before as far as I remember so I'm at a loss :(

kutuup 25 Junior Poster in Training

Ah, dammit! It's always something so obvious! lol thanks guys. As for memory allocation and freeing memory, the code isn't finished yet, I'll be implementing that later :P

kutuup 25 Junior Poster in Training

I am not sure why but this code (an attampt at a point and click game engine using Allegro 5) throws up an unhandled exception. The program starts and displays a picture, but as soon as the mouse is moved the exception pops up and the program crashes. I have highlighted the line (154) the IDE points to when it pops the exception message.

Any ideas on why would be greatly appreciated. I've been thinking about this all day and can't find the problem :(

// Adventure.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <allegro5/allegro.h>
#include <allegro5/allegro5.h>
#include <allegro5/allegro_image.h>
#include <allegro5/allegro_primitives.h>
#include <allegro5/allegro_font.h>
#include <allegro5/allegro_ttf.h>
#include <allegro5/allegro_audio.h>
#include <allegro5/allegro_acodec.h>
#include <iostream>
#include "string.h"
#include <windows.h>

using namespace std;

ALLEGRO_DISPLAY *display = NULL;
ALLEGRO_BITMAP *screenBitmapBuffer;
ALLEGRO_EVENT ev;
ALLEGRO_EVENT_QUEUE* event_queue = NULL;

class hotspot
{
private:
	string pairedScreen;
	string link;
public:
	int a,b,c,d;

	hotspot(string link, int a, int b, int c, int d)
	{
		this->link = link;
		this->a = a;
		this->b = b;
		this->c = c;
		this->d = d;
	}
};

class screen
{
private:

	ALLEGRO_BITMAP* imageStatic;
	hotspot* hotspots[8];

public:

	screen(const char* imageStatic)
	{
		this->imageStatic = al_load_bitmap(imageStatic);
	    this->hotspots[1] = new hotspot("test2",0,0,100,100);
		this->hotspots[2] = NULL;
		this->hotspots[3] = NULL;
		this->hotspots[4] = NULL;
		this->hotspots[5] = NULL;
		this->hotspots[6] = NULL;
		this->hotspots[7] = NULL;
		this->hotspots[8] = NULL;

	}
	screen()
	{
		this->imageStatic = NULL;
	}
	void display()
	{
		cout << this->imageStatic << endl;
		al_draw_bitmap(this->imageStatic,0,0,0);
		al_flip_display();
	}
	void setBitmap(const char* filename)
	{
		this->imageStatic = al_load_bitmap(filename);
	}
	hotspot* checkHotspot(int x)
	{
		return …
kutuup 25 Junior Poster in Training

Can you post your full code please?

Yes. Here it is :P

It's quite lengthy and completely linear, need to get round to making it more modular and using classes etc. When I started programming it I got lazy lol

// Turnover.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <windows.h>
#include "turnoverengine.h"
#include <allegro5/allegro.h>
#include <allegro5/allegro5.h>
#include <allegro5/allegro_image.h>
#include <allegro5/allegro_primitives.h>
#include <allegro5/allegro_font.h>
#include <allegro5/allegro_ttf.h>
#include <allegro5/allegro_audio.h>
#include <allegro5/allegro_acodec.h>
#include <iostream>
#include <fstream>
#include <mmsystem.h>
#include <process.h>
#include "math.h"
#include "string.h"
#include <sstream>


using namespace std;

ALLEGRO_DISPLAY *display = NULL;
ALLEGRO_DISPLAY *backdrop = NULL;
ALLEGRO_BITMAP* nought;
ALLEGRO_BITMAP* cross;
ALLEGRO_BITMAP* wall;
ALLEGRO_BITMAP* blank;
ALLEGRO_BITMAP* particle;
ALLEGRO_BITMAP* splash;
ALLEGRO_BITMAP* splash2;
ALLEGRO_BITMAP* standard;
ALLEGRO_BITMAP* random;
ALLEGRO_BITMAP* pass;
ALLEGRO_BITMAP* highlight;
ALLEGRO_BITMAP* movehighlight;
ALLEGRO_EVENT ev;
ALLEGRO_EVENT_QUEUE* event_queue;
ALLEGRO_MOUSE_STATE mousestate;
ALLEGRO_FONT *font;
ALLEGRO_TIMER *timer = NULL;
ALLEGRO_SAMPLE *bgm = NULL;

//ALLEGRO_COLOR color = al_map_rgba_f(1.0, 0.4, 0.6, 0); // <-- correct

const float FPS = 60;

int alpha = 128;

int score = 0;
int milliseconds = 0;
int seconds = 0;

int lastmove[2];

int resetmap[10][10];

int map[10][10];

int lastmousepos[2];
int currmousepos[2];

int validmove1[2];
int validmove2[2];
int validmove3[2];
int validmove4[2];

string loadtexturestring;
string points;
string gametimer;

int mode;

int clickx;
int clicky;

int mousex;
int mousey;

int moves;
int currlevel;
char nextLeveld1 = '0';
char nextLeveld2 = '0';
int multiplesOfTen = 0;

int tilesize = 100;



	int drawbufferx = 0;
	int drawbuffery = 0;

	template <class T>
	string to_string (const T& t)
	{
		stringstream ss;
		ss << t;
		return ss.str(); …
kutuup 25 Junior Poster in Training

Hi all,

I'm just working on a little Allegro 5 puzzle game for a bit of fun and practise between jobs.

Anyway, I have a bit of an optimization issue. It's a board based game where you have an 8x8 board with each square having a value of 0-3 representing what is on the square, this info is saved in an array.

So I want the squares to be highlighted when the mouse is positioned over them. I've done this by adding a function that whenever the mouse is moved, checks to see it it is now over a different square, and if it is, draws a bitmap over the square which highlights it. However, the function currently redraws the entire board every time it draws the highlight sprite since the screen goes black, just drawing the highlighter sprite if I don't call my redraw function.

Can anyone suggest a way that I can either just redraw the square the mouse is over rather than the whole board or store the board (made up of 64 bitmaps drawn to the screen) as a new bitmap and just draw that to the screen as 1 bitmap each time the funciton is called rather than each of the 64 bitmaps individually?

Here is my code for this function:

if(ev.type == ALLEGRO_EVENT_MOUSE_AXES && ev.mouse.x < 500 && ev.mouse.y < 500)
		{
			mousex = ev.mouse.x/50;
			mousey = ev.mouse.y/50;
			currmousepos[0] = mousey*50;
			currmousepos[1] = mousex*50;
			if(currmousepos[0] != lastmousepos[0] || …
kutuup 25 Junior Poster in Training

After busting my balls for days over this, turns out that was the problem, I was using the Allegro version compiled for VC++ 2005 instead of the correct VC++ 2010 build :S

Rookie mistake but at least it got sorted and I learned something lol

Now to figure out why I don't seem to have the debug version of the msvcr100 dll :P

kutuup 25 Junior Poster in Training

Hey all,

Just trying to build a program in VS2008 using the Allegro library.

When I try to build (debug or release), the build completes, but when the program tries to run, I get an error saying that a file called "MSVCR80D.dll" is missing and suggests reinstalling the program.

I can't find any answers as to why this might be online, but I worked on this program on a previous install of Win7 also using VS2008 and did not have this problem :(

Any advice would be greatly appreciated!


James

I think I may have found the problem, the error may be caused not by the fact that my program uses the VC++ 2005 redist (which it doesn't since I have now copied all the code over to a new project which has never touched VS 2005), but the allegro library I am linking may be causing the issue if it was compiled using VC++ 2005. This still doesn't explain why I am missing the redists after installing them.

kutuup 25 Junior Poster in Training

OK I'll get that sorted, thanks again for your help!

OK I have it all set up but I think I need your email to invite you to look at the files? Sorry never used Dropbox before :S

kutuup 25 Junior Poster in Training

You place them in your public folder. As a zip file. Then you click on the arrow on the right hand side and click on public link or copy link something like that.

I'm actually heading out now. I won't be back for several hours, but when I get back, I will definitely look at the software for you.

OK I'll get that sorted, thanks again for your help!

kutuup 25 Junior Poster in Training

megaupload, fileupload, yousendit, dropbox (my favourite) *shrugs* many places...just not file planet. They are evil.

I've made a Dropbox account, how do I give you access to the files?

kutuup 25 Junior Poster in Training

Hmm, upload your executable and any dynamic non-standard libraries you require. I think we need to ascertain if it's the build process or the machine that is the problem.

Curiously enough, if I go to my last backup of the built and compiled program I made before the windows reinstall and run it, it works fine! That suggests to me it's a config problem :S

Where can I upload those files to for you to look at? I appreciate the help!

kutuup 25 Junior Poster in Training

If you've tried running the release version after installing the x86 and x64 2005 runtimes then there is a problem with your computer.

Those files are supposed to be installed into the GAC and are pulled when a library is requested. The OS handles that.

Also, if you're building with 2008/2010 and it's saying you're missing the 2005 run time, check that you haven't included any specific libraries in the linker. Otherwise, create a new project in 2008/2010 and put the files from the old project into the new one. If it's an up-conversion from 2005 there may still be legacy scripts for the build which weren't converted.

Also, I appreciate that you said you tried both builds but you only mentioned MSVCR80D.DLL and that was before you'd installed the 2005 runtime. Now that you've installed the 2005 runtime it would be worth you rebuilding them and attempting to run the application again.

EDIT: Post a link to your executable and the supporting libraries. That way we can see if this is a build problem or a problem with the target machine.

I have included the Allegro 5 library in the linker which may require the VC2005 redist, but I have installed it on the machine so why the msvcr80 dlls are still not found is beyond me. I've tried rebuilding them numerous times to no avail.

kutuup 25 Junior Poster in Training

MSVCR80D.dll is part of the Visual Studio 2005 Runtime DEBUG library. Although why you would need this if you're building in 2010/2008 I have no idea. In any case, so long as that version of visual studio is installed you should have no problem running the program.

To get around this issue, you can compile your project in Release mode or change the Runtime library from /MTd to /MT

The other option is to installed Visual Studio 2005.

If you read over previous posts, we have already tried both Debug and Release builds, both produce the same error when running the build except the release build reports MSVCR80.dll missing instead on MSVCR80D.dll. Both files are apparently missing from my system.

kutuup 25 Junior Poster in Training

I've had a look in that folder and I only have the redists for VC++ 2008 (I think, they are the number 90 dlls). I've installed every conceivable redist and they still haven't shown up. It can't be a compatibility issue since I seemed to have the file on my last install of Win7 x64, which is exactly what I'm using now with the same version of VS as before since I didn't get this error.

Is there some setting to tell VS which redist to use so I can set it to use msvcr90 istead of 80? Are they that different?

Sorry, I'm a recent graduate and am still learning all this stuff.

kutuup 25 Junior Poster in Training

Perhaps the program you are running is depend on the dll which was declared to be missed.
Try to download such files and put it into the system32 root

I'm fairly sure that when I made the program I was using VC++2008 redist, since I programmed it with Visual Studio 2008. What's confusing me is when I reinstall the redists, the corresponding files aren't added to my system :S

I've been advised against getting the files from dll sites, are they risky?

kutuup 25 Junior Poster in Training

Then we're back to a configuration error in your IDE/Compiler.

OK at least we're narrowing it down, are there any particular settings I should check? Is there maybe a setting for what redist package to use?

Sorry I'm not too familiar with project setup/linking etc :(

kutuup 25 Junior Poster in Training

Downloaded and installed. No joy. The redist packs don't seem to actually provide any files. I've installed: VC++ 2005 (x86 and x64), VC++ 2008 (x86 and x64) and VC++ 2010 (x64) and the only msvcr file I have in system32 is msvcr100.dll

This is getting weird.

kutuup 25 Junior Poster in Training

It must be something in either your VS Project or your Allegro configuration then. I'm afraid I can't help you with Allegro.

Maybe someone who knows a little more about the "nuts and bolts" of project configuration will be able to help you.

Are you able to find the "missing" file on your system?

I can't find the file anywhere on my computer, I've installed the redist for VC++ 2008 and that didn't seem to install the file to anywhere I can see, it's definitely not in the system32 folder and if I run a search for it it isn't found.

kutuup 25 Junior Poster in Training

Downloaded and installed the redist for Visual C++ 2008, file is still apparently missing.

kutuup 25 Junior Poster in Training

I've run it, still got the same problem :(

kutuup 25 Junior Poster in Training

I've had this issue once.You need to rerun the configuration batch file (.bat | .cmd) situated in the bin\ directory.

I'm sorry, the .bat file in which bin directory? You mean Visual Studio? I'm looking at the directory and can't see a config.bat file or anything that looks like a configuration .bat, would you happen to know the exact name of the file?

kutuup 25 Junior Poster in Training

I should add, if I look in the system32 folder there is a file called MSVCR100D.dll

Is that a newer version of the same file?

kutuup 25 Junior Poster in Training

Hey all,

Just trying to build a program in VS2008 using the Allegro library.

When I try to build (debug or release), the build completes, but when the program tries to run, I get an error saying that a file called "MSVCR80D.dll" is missing and suggests reinstalling the program.

I can't find any answers as to why this might be online, but I worked on this program on a previous install of Win7 also using VS2008 and did not have this problem :(

Any advice would be greatly appreciated!


James

kutuup 25 Junior Poster in Training

MSVCR90D.dll is a debug DLL (which is what the D at the end means). Sounds like you are trying to mix files compiled for debug with others compiled for release mode. Calling DLLs compiled for debug may also produce that error.

Here are other suggestions to try

Thank you! It's sorted! One of the Allegro dll's (Allegro_Monolith_Md) I was linking to was the debug version of the dll, swapped it out for the standard one and it worked!

I've been tearing my hair out over it and it was so simple, thanks again!

Lesson learned I guess :P

kutuup 25 Junior Poster in Training

You can set windows to show all file extensions, whereas typically it will "hide extensions for known file-types" which is the folder option you uncheck.

Ah that will prevent me making this mistake again! Thanks!

kutuup 25 Junior Poster in Training

Found the issue, turns out the file was saved as "level1.txt.txt"... Whoops :S

kutuup 25 Junior Poster in Training

I'm trying to read integers in a .txt file into a 2 dimensional array (map).

Here is the function:

void loadmap(int mapnum)
	{
		 int x;
		 ifstream inFile;

		 inFile.open("level1.txt");
		 if (!inFile) 
		 {
				cout << "Unable to open file";
				//exit(1); // terminate with error
		}


		for(int countline = 0; countline <= 9; countline++)
		{
			for(int count = 0;count <= 9; count++)
			{
				while(inFile >> x)
				{
				map[count][countline] = x;
				}
			}
		}
		memcpy(resetmap,map,sizeof resetmap);
		inFile.close();

	}

The problem is, the function does not seem to find the file (level1.txt). The file is in the root folder for the program. The console just outputs "unable to open file." and all the values in the array (map) default to 0.

Why might this be?

I now have the file in every concievable folder the program could be reading from and it still doesn't seem to find it. I can't see the problem! Could it be that this is a fault with Windows 7 or VS2008?

kutuup 25 Junior Poster in Training

I don't think it doesn't find it but your method of checking whether it has is wrong.
Instead try

if (inFile.is_open())

No joy with that, I've changed the code to:

void loadmap(int mapnum)
	{
		 int x;
		 ifstream inFile;

		 inFile.open("level1.txt");
		 if (!inFile.is_open()) 
		 {
				cout << "Unable to open file";
				//exit(1); // terminate with error
		}


		for(int countline = 0; countline <= 9; countline++)
		{
			for(int count = 0;count <= 9; count++)
			{
				while(inFile >> x)
				{
				map[count][countline] = x;
				}
			}
		}
		memcpy(resetmap,map,sizeof resetmap);
		inFile.close();

	}

But the result is the same. I've tried moving the file around in case it's in the wrong folder. In fact, it's now in every folder :P That hasn't fixed it either.

kutuup 25 Junior Poster in Training

I'm trying to read integers in a .txt file into a 2 dimensional array (map).

Here is the function:

void loadmap(int mapnum)
	{
		 int x;
		 ifstream inFile;

		 inFile.open("level1.txt");
		 if (!inFile) 
		 {
				cout << "Unable to open file";
				//exit(1); // terminate with error
		}


		for(int countline = 0; countline <= 9; countline++)
		{
			for(int count = 0;count <= 9; count++)
			{
				while(inFile >> x)
				{
				map[count][countline] = x;
				}
			}
		}
		memcpy(resetmap,map,sizeof resetmap);
		inFile.close();

	}

The problem is, the function does not seem to find the file (level1.txt). The file is in the root folder for the program. The console just outputs "unable to open file." and all the values in the array (map) default to 0.

Why might this be?

kutuup 25 Junior Poster in Training

Hi all,

I'm trying to build a program in visual studio 2008, when I build in debug mode, it runs just fine, but if I try to build in release mode, there are no errors but when the program runs I get this error:

The program can't start because MSVCR90D.dll is missing from your computer. Try reinstalling the program to fix this problem.

If I run the program in debug mode from within visual studio, it runs fine. If I go to the debug folder and run the exe it also runs fine. However, if I try to run the exe in the release folder I get the same error.

Any ideas?

kutuup 25 Junior Poster in Training

Scratch that, found the problem, for some reason I had a duplicate displaycontroller.h file, one of them blank, for some reason it was reading the blank one!

kutuup 25 Junior Poster in Training

Still no solution my end. Whatever I try I still get this error, could it be a Visual Studio bug?

kutuup 25 Junior Poster in Training

Error 1 error C2248: 'DisplayController::display' : cannot access private member declared in class 'DisplayController' c:\users\james\documents\visual studio 2008\projects\red ice 1.0\red ice 1.0\red ice 1.0.cpp 93

That's the text the error gives.

There are other errors too:

Error 2 error C2064: term does not evaluate to a function taking 0 arguments c:\users\james\documents\visual studio 2008\projects\red ice 1.0\red ice 1.0\red ice 1.0.cpp 93

Error 3 error C2039: 'ev' : is not a member of 'DisplayController' c:\users\james\documents\visual studio 2008\projects\red ice 1.0\red ice 1.0\red ice 1.0.cpp 95

Sorry, typo, that should read "display()

Error 4 error C2228: left of '.type' must have class/struct/union c:\users\james\documents\visual studio 2008\projects\red ice 1.0\red ice 1.0\red ice 1.0.cpp 95


The second error also confuses me since Display() most definitely is a member function of DisplayController:

class DisplayController
{
public:

    int bitmapx;
	int bitmapy;

   // ALLEGRO_DISPLAY display;
	ALLEGRO_BITMAP *crosshairs; 
	ALLEGRO_EVENT ev;
	ALLEGRO_EVENT_QUEUE *event_queue;

	void display()
	{
						this->event_queue = al_create_event_queue();
						al_register_event_source(event_queue, al_get_mouse_event_source());
						al_wait_for_event(event_queue, &ev);
						
		        	    this->crosshairs = al_load_bitmap("crosshairs.bmp");
		                if(!crosshairs)
						{
							fprintf(stderr,"Bitmap is null!");
							al_rest(2.0);
						}
               
				if(ev.type == ALLEGRO_EVENT_MOUSE_AXES || ev.type == ALLEGRO_EVENT_MOUSE_ENTER_DISPLAY)
				{
                   bitmapx = (ev.mouse.x -60);
				   bitmapy = (ev.mouse.y -60);
		           al_draw_bitmap(crosshairs,bitmapx,bitmapy,0);
		           al_flip_display();
				}

		       //al_rest(2.0);
	}

	bool mouseClicked()
	{
		if(ev.type == ALLEGRO_EVENT_MOUSE_BUTTON_UP)
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	DisplayController()
	{
		//this->display = new ALLEGRO_DISPLAY;
		this->bitmapx = 0;
		this->bitmapy = 0;
	}
	~DisplayController()
	{
	}
};

Sorry, typo, that should read "display() most definitely is a member function of DisplayController".

kutuup 25 Junior Poster in Training

Error 1 error C2248: 'DisplayController::display' : cannot access private member declared in class 'DisplayController' c:\users\james\documents\visual studio 2008\projects\red ice 1.0\red ice 1.0\red ice 1.0.cpp 93

That's the text the error gives.

There are other errors too:

Error 2 error C2064: term does not evaluate to a function taking 0 arguments c:\users\james\documents\visual studio 2008\projects\red ice 1.0\red ice 1.0\red ice 1.0.cpp 93

Error 3 error C2039: 'ev' : is not a member of 'DisplayController' c:\users\james\documents\visual studio 2008\projects\red ice 1.0\red ice 1.0\red ice 1.0.cpp 95

Error 4 error C2228: left of '.type' must have class/struct/union c:\users\james\documents\visual studio 2008\projects\red ice 1.0\red ice 1.0\red ice 1.0.cpp 95


The second error also confuses me since Display() most definitely is a member function of DisplayController:

class DisplayController
{
public:

    int bitmapx;
	int bitmapy;

   // ALLEGRO_DISPLAY display;
	ALLEGRO_BITMAP *crosshairs; 
	ALLEGRO_EVENT ev;
	ALLEGRO_EVENT_QUEUE *event_queue;

	void display()
	{
						this->event_queue = al_create_event_queue();
						al_register_event_source(event_queue, al_get_mouse_event_source());
						al_wait_for_event(event_queue, &ev);
						
		        	    this->crosshairs = al_load_bitmap("crosshairs.bmp");
		                if(!crosshairs)
						{
							fprintf(stderr,"Bitmap is null!");
							al_rest(2.0);
						}
               
				if(ev.type == ALLEGRO_EVENT_MOUSE_AXES || ev.type == ALLEGRO_EVENT_MOUSE_ENTER_DISPLAY)
				{
                   bitmapx = (ev.mouse.x -60);
				   bitmapy = (ev.mouse.y -60);
		           al_draw_bitmap(crosshairs,bitmapx,bitmapy,0);
		           al_flip_display();
				}

		       //al_rest(2.0);
	}

	bool mouseClicked()
	{
		if(ev.type == ALLEGRO_EVENT_MOUSE_BUTTON_UP)
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	DisplayController()
	{
		//this->display = new ALLEGRO_DISPLAY;
		this->bitmapx = 0;
		this->bitmapy = 0;
	}
	~DisplayController()
	{
	}
};
kutuup 25 Junior Poster in Training

You'd need to have it move left or right every few milliseconds using a timer system, then check what the square next to it is each iteration, if the next square is an X (wall I presume), turn around, or move in the opposite direction (+ or -) along the X or Y axis.

kutuup 25 Junior Poster in Training

Should probably clarify what state the program is in with that code.

Both the client and server compile and run, but the server just plays out the game by itself, and the client doesn't update its board with the data coming through from the server. I put an output to check what data was being sent and recieved, and it always seems to read 0. I tried changing the & operator when in the Play function, which is supposed to turn on one of the bits in boardStat.playerData, to an | but this causes an unhandled exception :S

kutuup 25 Junior Poster in Training

Hi,

I'm working on an assignment where we have to have a client and server sending each other an integer that represents a noughts and crosses board. I had it working by simply sending back and forth the entire NoughtsAndCrosses class, but now we need to do it just using the integers in the GameData struct using the individual bits. This is where I've gotten lost, here is my code, I'm not looking for straight up answers since I need to learn for myself, maybe just some hints to nudge me in the right direction?

I think there is a problem with my logic in the Play function of the BitNoughtsAndCrosses class and I think I've messed up the sending and recieving.

Server Code:

#include "stdafx.h"
#include <stdio.h>
#include <winsock2.h>
#include <iostream>
#include <ctime> 
#include <math.h>
#include <ws2tcpip.h>



using namespace std;

		const int bits[9] = {1,2,4,8,16,32,64,128,256};

//#define NORMAL 1
#define BITWISE 1


// Noughts and Crosses (Tic Tack Toe) game
class NoughtsAndCrosses{
protected:
	// 3 by 3 board is represented as a one dimensional array
	char board[9];
	// Players symbols are either X or O
	char playerSymbol;
	char aiSymbol;
	// Game state
	bool playerWin,aiWin,draw;
	// If there is a winner or a draw update the state
	bool CheckWin(char symbol){	
		bool won = false;
		// Is there a winner?
		// Check horizontal 
		if (board[0] == symbol && board[1] == symbol && board[2] == symbol) won = true;
		if (board[3] == symbol && board[4] == symbol && board[5] …
kutuup 25 Junior Poster in Training

All data in a digital computer is bits and bytes, effetively 0/1 strings. Datatypes of any sort are just interpretations of these data. Your job here is to serialise your object into a string of bytes before transmittions and recreate the object after it has been transmitted. Easiest to understand is probably the following: Write all the member variables of your object into a character-string (using string stream operators or sprintf, or whatever method you are familiar with). This way you have serialised the object into char's. Transmit this string and at the receiving end read the values back into memory and create an object using those values.
You have to think about what you want to do in case your object has complex members and/or pointers to other objects, but the general approach is the same.
Obviously this method is not very efficient, but once you've done it this way you can think about ways to improve permance.
Also you can have a look at the boost serialisation library if you are interested.
http://www.boost.org/doc/libs/1_46_1/libs/serialization/doc/index.html

Ah, I hadn't heard or thought of this concept!

I was just thinking about it the wrong way.

Thanks! The info was really helpful :)

kutuup 25 Junior Poster in Training

I've trawled the internet searchiing for an explaination on how to do this.

I'm working on an assignment and we are told to "transmit a whole object to the server".

As far as I know, the send function of winsock2 only allows you to send data of type char, so how can you transmit an object? Is there a way to convert an object to type char and then convert it back to an object the other end?

I'm at a loss here!

kutuup 25 Junior Poster in Training

Are the ALLEGRO_BITMAP, ALLEGRO_EVENT, ALLEGRO_EVENT_QUEUE identifiers macros, or just normal types?

Sorry, I'm not sure what you mean, they are classes declared in the Allegro library I presume. Either that or they are normal types, not sure what a macro is.

kutuup 25 Junior Poster in Training

where did you initialize the 'mainDisplay' object?

Outside the main function, at the top of the file (the code I pasted is just the main function), it's a global variable, is that bad?

I declared it thusly

DisplayController * mainDisplay = new DisplayController();
kutuup 25 Junior Poster in Training

Maybe something to do with creating the function with no prototype? Normally you would separate class into a .h and .cpp file. Not sure though, maybe you don't need prototypes in classes

I've always declared classes this way before and had no problems :S

kutuup 25 Junior Poster in Training

No suggestions? I'm totally at a loss here :(

kutuup 25 Junior Poster in Training

Some more code would be helpful, like the relevant part of your main(). The only errors I see as far as class setup goes are that your constructor and destructor have return types, which isn't allowed.

Here is the main function:

int main(int argc, char **argv)
{

   if(initialize() == false)
   {
   fprintf(stderr, "initialization failed!");
   al_rest(1.0);
   return 0;
   }

   al_rest(2.0);


	while(true)
	{
		al_clear_to_color(al_map_rgb(0,0,0));
		mainDisplay->display();
		al_flip_display();
		if(mainDisplay->ev.type == ALLEGRO_EVENT_MOUSE_BUTTON_UP)
		{
					break;
		}
	}
 
   al_destroy_display(display);
 
   return 0;
}

I've removed the return types on the constructor and destructor too, they weren't throwing up any errors which is odd :S

The error points to the line: mainDisplay->display();

kutuup 25 Junior Poster in Training

I have no idea what is going on here, first, the code:

#pragma once

#include <stdio.h>
//#include <stdafx.h>
#include <allegro5/allegro.h>
//#include <allegro_image.h>

class DisplayController
{
public:

    int bitmapx;
	int bitmapy;

   // ALLEGRO_DISPLAY display;
	ALLEGRO_BITMAP *crosshairs; 
	ALLEGRO_EVENT ev;
	ALLEGRO_EVENT_QUEUE *event_queue;

	void display()
	{
						this->event_queue = al_create_event_queue();
						al_register_event_source(event_queue, al_get_mouse_event_source());
						al_wait_for_event(event_queue, &ev);
						
		        	    this->crosshairs = al_load_bitmap("crosshairs.bmp");
		                if(!crosshairs)
						{
							fprintf(stderr,"Bitmap is null!");
							al_rest(2.0);
						}
               
				if(ev.type == ALLEGRO_EVENT_MOUSE_AXES || ev.type == ALLEGRO_EVENT_MOUSE_ENTER_DISPLAY)
				{
                   bitmapx = (ev.mouse.x -60);
				   bitmapy = (ev.mouse.y -60);
		           al_draw_bitmap(crosshairs,bitmapx,bitmapy,0);
		           al_flip_display();
				}

		       //al_rest(2.0);
	}

	bool mouseClicked()
	{
		if(ev.type == ALLEGRO_EVENT_MOUSE_BUTTON_UP)
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	void DisplayController()
	{
		//this->display = new ALLEGRO_DISPLAY;
		this->bitmapx = 0;
		this->bitmapy = 0;
	}
	void ~DisplayController()
	{
	}
};

So when I call that display function from main (objectName->display()), I get the private member error message, even though I've explicity stated that the function is public about 6 lines above! There's nothing in that class declared as private so why does the compiler seem to think it's private?

kutuup 25 Junior Poster in Training

Check http://msdn.microsoft.com/en-us/library/fwkeyyhe(v=VS.90).aspx and look for /Gr /Gz or /Gd compiler options.

Thanks, it did turn out to be a compiler issue. I couldn't find out how to fix it so I reverted to a backup and added my code back in, which solved the problem.

kutuup 25 Junior Poster in Training

Compiler (C/C++) advanced setting -> Calling convention should be the same for all files in your VS project. __fastcall (/Gr) is preferable for "Release" builds.

Sorry, what does that mean? lol I don't see any options like that in VS2008.

kutuup 25 Junior Poster in Training

The simple sample below creates a similar error, if the definition of ~Client is missing. In your case althought the definition exists, the linker seems to not see it. When I get into this type of problem, I strip the code to its bare essentials and usually the problem becomes obvious.

class Client
{
public:
Client();
~Client();
};

Client::Client()
{
}

#ifdef MISSING
Client::~Client()
{
}
#endif
 
int main()
{
   Client c;
   return 0;
}
 
test2.obj : error LNK2019: unresolved external symbol "public: __thiscall Client::~Client(void)" (??1Client@@QAE@XZ) referenced in function _main

I don't understand, so the definition is there in my code? So what is the problem?