Jump to content

  • Log In with Google      Sign In   
  • Create Account


GameC++Expert93

Member Since 28 Sep 2012
Offline Last Active Oct 07 2012 01:29 PM

Topics I've Started

Need alittle help in allegro please

02 October 2012 - 01:19 PM

Hey this is the first game ive built using sprites/bitmap images im just curious how do you make a bitmap move in allegro? in using c++ btw thanks in advance. This is what i have so far

game.h
#ifndef GAME_H_INCLUDED
#define GAME_H_INCLUDED
/**
*Include allegro and the std library
**/
#include <stdlib.h>
#include "allegro.h"
/**Sprite bitmap**/
BITMAP* ship;
BITMAP* enemy;
BITMAP* laser;
BITMAP* enemyLaser;
/**
*DEFINE SOME MAIN GAME CONSTANTS
**/
#define WIDTH  640
#define HEIGHT 480
#define LIVES 4
/**
*DEFINE SOME COLORS
**/
#define TAN makecol(255,242,169)
#define BURST makecol(255,189,73)
#define BLACK makecol(0,0,0)
#define WHITE makecol(255,255,255)
#define GRAY makecol(128,128,128)
#define GREEN makecol(0,255,0)
/**
*DEFINE SPRITE FILES WE NEED TO LOAD
**/
#define SHIP "ship.bmp"
/**
*Buffer
**/
BITMAP* buffer;
/**
*Define some variables
**/
int score = 0;//Players score
/**
*DEFINE A SPRITE STRUCTURE
**/
typedef struct SPRITE{
int dir;
int x,y;
int Xspeed,Yspeed;
}SPRITE;
SPRITE* Ship;

#endif // GAME_H_INCLUDED


main.cpp
#include "game.h"
/**
*Draw everything to the screen
**/
void draw(){
acquire_screen();
draw_sprite(screen,buffer,0,0);
draw_sprite(screen,ship,100,300);
release_screen();
rest(50);
}
/**
*Handles movement of our players ship
**/
void moveShip(){
if(key[KEY_RIGHT]){
--Ship->x;
}
}
/**
*SETUP OUR GAME
**/
void GameSetup(){
draw();
}
void Enemy_Handle(){}

int main()
{
	//Initialize Allegro
	allegro_init();
	 /**Set color depth to 32**/
	set_color_depth(32);
	//Set the resolution to 640 x 480 with SAFE autodetection.
	set_gfx_mode(GFX_SAFE, WIDTH, HEIGHT, 0, 0);
	 //Install the keyboard handler
  install_keyboard();
  buffer = create_bitmap(WIDTH,HEIGHT);
  ship = load_bitmap(SHIP,NULL);
  GameSetup();
	//Loop until escape is pressed
	while(! key[KEY_ESC])
		poll_keyboard();
		 moveShip();
	return 0;
}
END_OF_MAIN();

Struggling a little

30 September 2012 - 10:27 AM

So yes i know my title has the word expert in it i honestly was just making up a name so don't poke fun please lol. Anyways ive coded c++ for quite awhile now and have c++ pretty much grasped but for the lights of me im really having a hard time in the game programming aspect because i do come from a web development background of programming in PHP for over 5 years but i really wanna dig deeper into game development with c++ and allegro. any ideas as to how to master programming games using the c++ language? i mean i have the basics down and can create small games like pong etc.. but its the bigger games id like some advice on how to plan and code thanks in advance.

Will teach c++ to beginners

28 September 2012 - 05:06 PM

Sorry if this is the wrong section please move it if so :) I have alot of spare time on my hands so if you are looking to get into game programming just message me and i will give you the run down of c++ programming related to games.. some things i will cover include..

1.Variables
2.Datatypes/Typecasting in c++
3.OOP in c++
4.Functions
5.Basics of game programming using the allegro library for c++
6.And more...

i do charge $10 an hour to teach which includes around 3-4 days a week an hour each day but if you wanna learn feel free to message me.

PARTNERS