Jump to content

  • Log In with Google      Sign In   
  • Create Account


Krishath

Member Since 02 Dec 2011
Offline Last Active Jul 25 2012 01:40 PM
-----

Topics I've Started

First steps...

24 July 2012 - 07:30 AM

Hello guys, I'm following the tutorials by LazyFoo but I tried to "design" the code by my own way... BUT (obviously) it crashes.
What am I doing wrong?

#include "SDL/SDL.h"
#include <string>
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480
#define SCREEN_BPP 32
SDL_Surface * screen = NULL;
SDL_Surface * image = NULL;
SDL_Event event;
bool init()
{
    if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
	    return false;
    if ((screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE)) == NULL)
	    return false;
    SDL_WM_SetCaption("LOL", NULL);
    return true;
}
SDL_Surface * load_image ( std::string filename )
{
    SDL_Surface * loadedImage = NULL;
    SDL_Surface * optimizedImage = NULL;
    loadedImage = SDL_LoadBMP(filename.c_str());
    if (loadedImage)
    {
	    optimizedImage = SDL_DisplayFormat(loadedImage);
	    SDL_FreeSurface(loadedImage);
    }
    return optimizedImage;
}
void apply_surface (int x, int y, SDL_Surface * source, SDL_Surface * destination)
{
    SDL_Rect offset;
    offset.x = x;
    offset.y = y;
    SDL_BlitSurface(source, NULL, destination, &offset);
}
void clean_up (SDL_Surface * image)
{
    SDL_FreeSurface(image);
    SDL_Quit;
}
int main (int argc, char * argv[])
{
    bool quit = false;
    if (!init)
	    return 1;
    image = load_image("background.bmp");
    apply_surface(0, 0, image, screen);
    SDL_Flip(screen);
    while (!quit)
	    while (SDL_PollEvent(&event))
		    if (event.type == SDL_QUIT)
			    quit = true;
    clean_up(image);
    return 0;
}
Thanks!

Let's have a good POV..

20 July 2012 - 02:02 AM

Hello guys, I just wanted to know how can I start developing games. Easy question, hard answer.
I already program in C, I've also tried the Allegro library but... I want to know how a game is developed. What's its structure, how should I create it, what tools should I use and so on. I would like to use professional-like tools (C++, OpenGL [open-source!]... etc) and maybe you can help me.

How can I understand C++ (coming from C, so I don't need the "ok, this thing is called variable" chapter) and OOP? What should I do next? Which books can help me in my project?

So to sum it up: what's the game structure? How can I make it work? How can I do it?
Suggest me books to buy and so on. Thank you guys!

PS: (this is quite OT but...) I'm not a native english speaker so I'd like some correction and some "grade" with my english. Thanks! (help me improve!)

[HELP] Need help with this source code

11 February 2012 - 07:06 AM

Hello guys! I've just started playing with Allegro and, with some tutorial, I've managed to create this little program with some "addiction" to try something new. I'm playing with functions and pointers and I think that I made some mistake while managing them.

Here's the source code (the debugger [VS2010] says that the code is broken in al_wait_for_event())
#include <stdio.h>
#include <allegro5\allegro5.h>
#include <allegro5\allegro_primitives.h>
#define WIDTH 800
#define HEIGHT 600
int init (ALLEGRO_DISPLAY *, ALLEGRO_EVENT_QUEUE *);
void loop (ALLEGRO_DISPLAY *, ALLEGRO_EVENT_QUEUE *, bool *, int *, int *, int *);
void destroy (ALLEGRO_DISPLAY *, ALLEGRO_EVENT_QUEUE *);
int main (int argc, char * argv[])
{
ALLEGRO_DISPLAY * display = NULL;
ALLEGRO_EVENT_QUEUE * event_queue = NULL;
bool done;
int pos_x, pos_y, mov;
done = false;
pos_x = 0;
pos_y = 0;
mov = 10;
if (!init(display, event_queue))
{
  loop(display, event_queue, &done, &pos_x, &pos_y, &mov);
  destroy(display, event_queue);
}
return 0;
}
int init (ALLEGRO_DISPLAY * display, ALLEGRO_EVENT_QUEUE * event_queue)
{
if (!al_init())
  return 1;
if (!(display = al_create_display(WIDTH, HEIGHT)))
  return 1;
if (!al_install_keyboard())
  return 1;
if (!al_init_primitives_addon())
  return 1;
if (!(event_queue = al_create_event_queue()))
  return 1;
al_register_event_source(event_queue, al_get_keyboard_event_source());
return 0;
}
void loop (ALLEGRO_DISPLAY * display, ALLEGRO_EVENT_QUEUE * event_queue, bool * done, int * pos_x, int * pos_y, int * mov)
{
ALLEGRO_EVENT ev;
while (!(*done))
{
  al_wait_for_event(event_queue, &ev);
  if (ev.type == ALLEGRO_EVENT_KEY_DOWN)
   switch (ev.keyboard.keycode)
   {
    case ALLEGRO_KEY_UP:
	 * pos_y -= * mov;
	 break;
    case ALLEGRO_KEY_DOWN:
	 * pos_y += * mov;
	 break;
    case ALLEGRO_KEY_LEFT:
	 * pos_x -= * mov;
	 break;
    case ALLEGRO_KEY_RIGHT:
	 * pos_x += * mov;
	 break;
    case ALLEGRO_KEY_X:
	 * mov += 5;
	 break;
    case ALLEGRO_KEY_Q:
	 * done = true;
	 break;
   }
  al_draw_filled_circle(* pos_x, * pos_y, 5, al_map_rgb(255,0,0));
  al_flip_display();
  al_clear_to_color(al_map_rgb(0,0,0));
}
return;
}
void destroy (ALLEGRO_DISPLAY * display, ALLEGRO_EVENT_QUEUE * event_queue)
{
al_destroy_display(display);
al_destroy_event_queue(event_queue);
return;
}
Let me know what you think about it!

Where do I start?

02 December 2011 - 12:37 PM

Hello guys, I know that this question has been asked thousands of time but I don't know what should I do to "create" a base for my future knowledge. I'm a Computer Science in a university and I'm currently developing on C. I'd love to take a master course in Game Development but, for that, I should wait 3 years (you know, you have to take a "first level" degree first! Posted Image) and sincerely I would like to start developing something right now. It can be anything, I just want to enter the "mentality" of GameDev. So, any suggestion? Thank you very much!

PS: Any good book?

[poll removed, please read the FAQ -- jpetrie]

PARTNERS