Jump to content
  • Advertisement
Sign in to follow this  
LAURENT*

My game's beta is finished but it won't run on other comptuers

This topic is 1471 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've come so far and now I'm almost ready to release my first beta. my beta doesn't work on other computers. I'm mainly talking about the application file. Anyways here some info. I used visual studios 2010 to create my game. The extension library is SDL 1.5 from lazy foo. When I run the application I can't seem to move my character with key press. How do you make visual studios 2010 applications run on other computers?

 

 

EDIT!

 

Here is my game source code included. This is a isometric platformer tic tact toe game. If you're looking to make tic tact toe or a isometric platformer use my source code for whatever you want. I don't really care.

 

https://www.mediafire.com/?9natkpirh64aded

Edited by LAURENT*

Share this post


Link to post
Share on other sites
Advertisement
#include <stdlib.h>
#include <stdio.h>
#include <SDL.h>
#include <SDL_image.h>
#include <time.h>
#include "tictactoe.h"

void Game::showMovement(int x, int y, SDL_Surface* screen, SDL_Surface* source, SDL_Rect* clip = NULL)
{
	//Holds offsets
    SDL_Rect offset;

    //Get offsets
    offset.x = x;
    offset.y = y;

    //Blit
    SDL_BlitSurface( source, clip, screen, &offset);
}


void Game::showCharacterMovement(int fakeX, int z, SDL_Surface* screen, SDL_Surface* source, SDL_Rect* clip = NULL)
{
	//Holds offsets
    SDL_Rect offset;

    //Get offsets
    offset.x = fakeX;
    offset.y = z;

    //Blit
    SDL_BlitSurface( source, clip, screen, &offset);
}


void Game::hub(SDL_Surface *screen)
{
	x = 0;
	y = 0;
	fakeX = x;
	z = y + YS_HEIGHT;
	
	bool quit = false;
	//While the user hasn't quit
    
	while( quit == false )
    {
        //While there's events to handle
        while( SDL_PollEvent( &event ) )
        {
            //Handle events for the dot
            buttonInput();

            //If the user has Xed out the window
            if( event.type == SDL_QUIT )
            {
                //Quit the program
                quit = true;
				break;
            }
        }
		
		move( get_ticks() );
		if ((x > 100 + 11) && (x < 100 + 31) && (y < 100 + 64 ) && (y > 100 + 58 )) 
		{   y = 0;
			x = 0;
			z = 0;
			xVel = 0;
			yVel = 0;
			zVel = 0;
			break;
			

		}
		start();
		SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 255, 255, 255));

		showMovement(100, 100, screen, Door1 );
		showMovement((int) x, (int)y, screen, LandPad );
		showCharacterMovement((int) fakeX, (int) z, screen, Ysguy1);
		SDL_Flip( screen );

		
	} 
	play(screen);
}


void Game::buttonInput()
{		
	//If a key was pressed
    if( event.type == SDL_KEYDOWN )
    {
        //Adjust the velocity
        switch( event.key.keysym.sym )
        {
			case SDLK_UP: yVel -= YS_VEL_WALK; zVel -= YS_VEL_WALK; break;
            case SDLK_DOWN: yVel += YS_VEL_WALK; zVel += YS_VEL_WALK; break;
            case SDLK_LEFT: xVel -= YS_VEL_WALK; break;
            case SDLK_RIGHT: xVel += YS_VEL_WALK; break;
			case SDLK_SPACE: if(grounded == true){z -= 3; zVel -= YS_VEL_WALK + 20;} break; 
							// if(grounded == false) {}
        }
    }
    //If a key was released
    else if( event.type == SDL_KEYUP )
    {
        //Adjust the velocity
        switch( event.key.keysym.sym )
        {
            case SDLK_UP: yVel += YS_VEL_WALK; zVel += YS_VEL_WALK; break;
            case SDLK_DOWN: yVel -= YS_VEL_WALK; zVel -= YS_VEL_WALK; break;
            case SDLK_LEFT: xVel += YS_VEL_WALK; break;
            case SDLK_RIGHT: xVel -= YS_VEL_WALK; break;	
        }
    }
}


void Game::move( Uint32 deltaTicks )
{	
	landpadCoords.x = x;
	landpadCoords.y = y;
	landpadCoords.w = x + LANDPAD_WIDTH;
	landpadCoords.h = y + LANDPAD_HEIGHT;
	
	
	
	fakeX = x; 
    //Move the dot left or right
    x += xVel * ( deltaTicks / 1000.f );

    //If the dot went too far to the left
    if( x < 0 )
    {
        //Move back
        x = 0;
    }
    //or the right
    else if( x + YS_WIDTH > SCREEN_WIDTH)
    {
        //Move back
        x = SCREEN_WIDTH - YS_WIDTH;
    }

    //Move the dot up or down
    y += yVel * ( deltaTicks / 1000.f );

    //If the dot went too far up
    if( y < 0 )
    {
        //Move back
        y = 0;
    }
    //or down
    else if( y + YS_HEIGHT > SCREEN_HEIGHT)
    {
        //Move back
        y = SCREEN_HEIGHT - YS_HEIGHT;
    }

	
	
	if (z + YS_HEIGHT > y)			
	{ 
		grounded = true;	
	}	
	else if (z + YS_HEIGHT < y)
	{
		grounded = false;
	}
		

	if (grounded == true)
	{
		zVel = yVel;
		z = y - YS_HEIGHT + 1;
	}		
	else if (grounded == false)
	{	
		zVel += ACCELARATION * ( deltaTicks / 1000.f );
		z += zVel * ( deltaTicks / 1000.f );
	}

	
}


Header file

#include <string>

class Game
{	 
	public:	
		//Game();

		Game::Game()
		{
			circle = IMG_Load("circle.jpg");  
			croix = IMG_Load("croix.jpg"); 
			board = IMG_Load("board.jpg"); 
			horizontale = IMG_Load("horizontale.jpg");
			verticale = IMG_Load("verticale.jpg");
			diagonale1 = IMG_Load("diagonale1.png");
			diagonale2 = IMG_Load("diagonale2.png");
			button = IMG_Load("button.png");
			Door1 = IMG_Load ("Door1.png");
			// Characters
			Ysguy1= IMG_Load("Ysguy1.png");
			LandPad = IMG_Load("LandPad.png");
			//Timer variables and functionality
			startTicks = 0;
			pausedTicks = 0;
			paused = false;
			started = false;

			//Const numbers that should never change
			 YS_VEL_WALK = 100;
			 YS_HEIGHT = 25;
			 YS_WIDTH = 19;
		     SCREEN_WIDTH = 589;
			 SCREEN_HEIGHT = 404;
			 ACCELARATION = 300;
			 LANDPAD_WIDTH = 19;
			 LANDPAD_HEIGHT = 7;
		};

		void meun (SDL_Surface* screen);
		void characters(SDL_Surface* screen);
		void play(SDL_Surface* screen); //F1
		int check_victory(SDL_Surface* screen); //F2	
		/***************************************************************************************/
		/////////////////////////////////////////////////////////////////////////////////////////
		////////////////////////////////MOVE PUBLIC FUNCTIONS///////////////////////////////////
		/////////////////////////////////////////////////////////////////////////////////////////
		/***************************************************************************************/
		
		void buttonInput();
		void hub(SDL_Surface* screen);
		void move (Uint32 deltaTicks);
		void showMovement(int x, int y, SDL_Surface* screen, SDL_Surface* source, SDL_Rect* clip);
		void showCharacterMovement(int x, int z, SDL_Surface* screen, SDL_Surface* source, SDL_Rect* clip);
		/***************************************************************************************/
		/////////////////////////////////////////////////////////////////////////////////////////
		////////////////////////////////TIMER PUBLIC FUNCTIONS///////////////////////////////////
		/////////////////////////////////////////////////////////////////////////////////////////
		/***************************************************************************************/
		void start();
		void stop();
		void pause();
		void unpause();

		//Gets the timer's time
		int get_ticks();

		//Checks the status of the timer
		bool is_started();
		bool is_paused();
			
		Game::~Game()
		{
			SDL_FreeSurface(horizontale);
			SDL_FreeSurface(verticale);
			SDL_FreeSurface(diagonale1);
			SDL_FreeSurface(diagonale2);
			SDL_FreeSurface(croix);
			SDL_FreeSurface(circle);
			SDL_FreeSurface(button);
			SDL_FreeSurface(board);	
			SDL_FreeSurface(Door1);	
			SDL_FreeSurface(LandPad);	
			SDL_FreeSurface(Ysguy1);	
		};

		//~Game();
		


	private:
		SDL_Event event;
		enum {EMPTY, CIRCLE, CROSS};
		
		/***************************************************************************************/
		/////////////////////////////////////////////////////////////////////////////////////////
		////////////////////////////////IMAGE PRINTING PRIVATE VARIABLES/////////////////////////
		/////////////////////////////////////////////////////////////////////////////////////////
		/***************************************************************************************/
		SDL_Surface *board, *circle, *croix, *horizontale, *verticale, *diagonale1, *diagonale2, *button, *Ysguy1, *LandPad, *Door1;
		
		
		int meunSelect;
		int continuer,  turn,  end, nowinner, xCoordinate, yCoordinate;
		int space1, space2, space3, space4, space5, space6, space7, space8, space9;  
		SDL_Rect boardPosition, positionforme, positionwon;
		SDL_Rect button1, button2, button3, button4, button5, button6, button7, button8, button9;
		bool quit;
		/***************************************************************************************/
		/////////////////////////////////////////////////////////////////////////////////////////
		////////////////////////////////TIMER PRIVATE VARIABLES//////////////////////////////////
		/////////////////////////////////////////////////////////////////////////////////////////
		/***************************************************************************************/
		//The clock time when the timer started
		int startTicks;

		//The ticks stored when the timer was paused
		int pausedTicks;

	    //The timer status
		bool paused;
		bool started;

		/***************************************************************************************/
		/////////////////////////////////////////////////////////////////////////////////////////
		////////////////////////////////MOVER PRIVATE VARIABLES//////////////////////////////////
		/////////////////////////////////////////////////////////////////////////////////////////
		/***************************************************************************************/
		float x, y, z;
		float fakeX;
		float xVel, yVel, zVel;
		float ACCELARATION;
		int YS_VEL_WALK;
		int YS_HEIGHT;
		int YS_WIDTH;
		int SCREEN_WIDTH;
		int SCREEN_HEIGHT;
		int LANDPAD_WIDTH;
		int LANDPAD_HEIGHT;
		int leftA, leftB;
		int rightA, rightB;
		int topA, topB;
		int bottomA, bottomB;

		bool grounded;
		
		SDL_Rect landpadCoords;
		
};


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!