Page 1 of 1

Game Won't Run On Macs or Vista

Posted: Sun Dec 14, 2008 10:58 pm
by knicholes
Hey, I wrote this 8puzzle game that works just fine on my PC but and it won't run on macs. Can anyone tell me what I can do to get it to work? My friends say they run the executable and then nothing happens. I compiled with MinGW gcc.

Here's just the beginning of my code. Maybe it has something to do with using "int"?

[Please use the code tag - Rogerborg]

Code: Select all

#include <iostream>
#include "Tile.h"
//#include "Board.h"
#include <conio.h>
#include <irrlicht.h>
#include <irrKlang.h>
using namespace irrklang;
using namespace irr;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
using namespace core;
using namespace std;

//int ROWSIZE = 3;
//int COLSIZE = 3;
enum {UP, DOWN, LEFT, RIGHT};
int swap(int);
Tile* getBlank();
int checkForWin();
u32 MAXTIME = 50000;
u32 WAITTIME = 80;
u32 MAXMOVES = 3000;
void wait();

class MyEventReceiver : public IEventReceiver
{
public:
        // This is the one method that we have to implement
        virtual bool OnEvent(const SEvent& event)
        {
                // Remember whether each key is down or up
                if (event.EventType == irr::EET_KEY_INPUT_EVENT)
                        KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown;
				//if (event.EventType == irr: EET_MOUSE_INPUT_EVENT)
				 return false;
        }

        // This is used to check whether a key is being held down
        virtual bool IsKeyDown(EKEY_CODE keyCode) const
        {
                return KeyIsDown[keyCode];
        }

        MyEventReceiver()
        {
                for (u32 i=0; i<KEY_KEY_CODES_COUNT; ++i)
                        KeyIsDown[i] = false;
        }

private:
        // We use this array to store the current state of each key
        bool KeyIsDown[KEY_KEY_CODES_COUNT];
};


int ROWSIZE = 3;
int COLSIZE = 3;
Tile* slots[3][3];
Tile* current;
int main()
{
        // let user select driver type
		
		
        video::E_DRIVER_TYPE driverType = video::EDT_DIRECT3D9;

        printf("Please select the driver you want for this example:\n"\
                " (a) Direct3D 9.0c\n (b) Direct3D 8.1\n (c) OpenGL 1.5\n"\
                " (d) Software Renderer\n (e) Burning's Software Renderer\n"\
                " (f) NullDevice\n (otherKey) exit\n\n");

        char i;
        std::cin >> i;

        switch(i)
        {
                case 'a': driverType = video::EDT_DIRECT3D9;break;
                case 'b': driverType = video::EDT_DIRECT3D8;break;
                case 'c': driverType = video::EDT_OPENGL;   break;
                case 'd': driverType = video::EDT_SOFTWARE; break;
                case 'e': driverType = video::EDT_BURNINGSVIDEO;break;
                case 'f': driverType = video::EDT_NULL;     break;
                default: return 0;
        }       

        // create device
        int userTime;
		cout << "How much time do you want? (in seconds)"<<endl;
		cin >> userTime;
		MAXTIME = userTime*1000;
		cout << "How many moves do you want?"<<endl;
		cin >> MAXMOVES;

..................

Posted: Mon Dec 15, 2008 12:57 am
by Ion Dune
What do you mean? You mean you compiled a win32 exe and it won't run on a mac? Or do you mean that this code won't compile on a mac? If so, what are the errors?

Also, I highly doubt it's because you're using "int" :lol:

Posted: Mon Dec 15, 2008 1:02 am
by twilight17
You have to compile it on the mac, you can't compile it on a PC, transfer over the .exe and run it. It has to be .app.

Posted: Mon Dec 15, 2008 1:31 am
by knicholes
So wait, if I just install MinGW on a Mac or a Vista machine and compile the very same source code I used on my XP machine, it will create an executable (or mac executable equivalent) that will work properly on similar machines? I don't have to do anything special with the compiler or with the programming language? (variable types)

I'm using the GCC libraries, .a files, for irrKlang and irrlicht. This makes a difference somehow, right?

Posted: Mon Dec 15, 2008 5:02 am
by twilight17
An int is an int across all compilers.

Posted: Mon Dec 15, 2008 9:56 am
by SwitchCase
twilight17 wrote:An int is an int across all compilers.
Not true. C++ standards do not actually clarify the size in bytes of defined types. Differing compilers and systems may use different definitions of the same types. That's why Irrlicht defines it's own types, abstracting type differences over different systems/environments.

Posted: Mon Dec 15, 2008 12:52 pm
by twilight17
In general use, an int is an int across all compilers. :lol: (They'll do the same thing)

For the sake of this thread:

@knicholes:
First question: yeah
Second question: usually you don't (unless you used platform specific code)
Third question: It's all good. :P

Posted: Mon Dec 15, 2008 7:53 pm
by bitplane
Since we don't provide a Makefile for OSX yet, it's easiest to just open the XCode project (in /source/Irrlicht/MacOSX/) and add your project to this. My first test worked with minimal adjustments to the game source (I moved the resources to inside the .app dir).
The only real problem I had was getting shift and ctrl key events working (Varmint provided some code which will be committed to the 1.5 branch before the official OSX 1.5 binary release).