home   |   contact us   |   sitemap   |   advertising Free Online Games
Free MMORPG

The Free MMORPG Games- Free MMORPG - P2P Games - Open Beta - Closed Beta - Browser Based - Non-English - Other Free Games - Top 50


Go Back   Onrpg Free MMORPG Forums > Development > General Programming
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old 07-24-2006, 02:51 AM   #1 (permalink)
naruto1327
Dante’s Inferno
 
naruto1327's Avatar
 
Join Date: May 2006
Location: California
Posts: 617
Reputation: 10
Send a message via AIM to naruto1327 Send a message via MSN to naruto1327 Send a message via Yahoo to naruto1327
MMOFaces Profile: None Yet
Default I need help with Allegro

Code:
#include <allegro.h>
void increment_speed_counter();
volatile long speed_counter = 0;
int main(int argc, char *argv[])
{
 	allegro_init();
 	install_keyboard();
 	install_timer();
	LOCK_VARIABLE(speed_counter);
	LOCK_FUNCTION(increment_speed_counter);
	install_int_ex(increment_speed_counter, BPS_TO_TIMER(60));
	set_color_depth(16);
	set_gfx_mode(GFX_AUTODETECT, 640,480,0,0);
	BITMAP *my_pic;
	my_pic = load_bitmap("image.bmp", NULL);
	BITMAP *buffer;
	buffer = create_bitmap(640,480);
	int my_pic_x = 0;
	int my_pic_y = 0;
	while(!key[KEY_ESC])
	{
		while(speed_counter > 0)
		{
			if(key[KEY_RIGHT])
			{
			my_pic_x++;
			}
			else if(key[KEY_LEFT])
			{
			my_pic_x--;
			}
			else if(key[KEY_UP])
			{
			my_pic_y--; 
			}
			else if(key[KEY_DOWN])
			{
			my_pic_y++;
			}
			speed_counter--;
		}
		draw_sprite(buffer, my_pic, my_pic_x, my_pic_y);
		blit(buffer, screen, 0,0,0,0,640,480);
		clear_bitmap(buffer);
	}
	destroy_bitmap(my_pic);
	destroy_bitmap(buffer);
	return 0;
}
END_OF_MAIN();
void increment_speed_counter()
{
	speed_counter++;
}
END_OF_FUNCTION(increment_speed_counter);
This is the main.cpp file.
The file "image.bmp" DOES exist, but nothing shows up. Just blackness...

Whats wrong?

Last edited by naruto1327 : 07-24-2006 at 02:53 AM.
naruto1327 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 07-24-2006, 10:40 AM   #2 (permalink)
TwitcH
Retired Staff
 
TwitcH's Avatar
 
Join Date: May 2006
Posts: 2,026
MMOFaces Profile: None Yet
Default

Do you have the image.bmp in the same folder as the source code?

If you do, then maybe giving allegro a more specific path to use may help:

Code:
my_pic = load_bitmap("c:\image.bmp", NULL);
Just my guess, never actually worked with allegro before and dont know alot of C++ , but I know enough to read through a C++ program and tell what it does and to me the source looks fine.
TwitcH is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 07-26-2006, 01:00 AM   #3 (permalink)
naruto1327
Dante’s Inferno
 
naruto1327's Avatar
 
Join Date: May 2006
Location: California
Posts: 617
Reputation: 10
Send a message via AIM to naruto1327 Send a message via MSN to naruto1327 Send a message via Yahoo to naruto1327
MMOFaces Profile: None Yet
Default

Yesh, they're both in the same folder:
D:\C++\main.cpp
D:\C++\image.bmp

Program works fine, but the image just doesn't appear.

Maybe it's something wrong with the image?
naruto1327 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 07-27-2006, 08:28 PM   #4 (permalink)
hamik
Bongo Crazy Kong
 
Join Date: Jul 2006
Posts: 232
Reputation: 10
MMOFaces Profile: None Yet
Default

Quote:
Originally Posted by naruto1327
Code:
#include <allegro.h>
void increment_speed_counter();
volatile long speed_counter = 0;
int main(int argc, char *argv[])
{
 	allegro_init();
 	install_keyboard();
 	install_timer();
	LOCK_VARIABLE(speed_counter);
	LOCK_FUNCTION(increment_speed_counter);
	install_int_ex(increment_speed_counter, BPS_TO_TIMER(60));
	set_color_depth(16);
	set_gfx_mode(GFX_AUTODETECT, 640,480,0,0);
	BITMAP *my_pic;
	my_pic = load_bitmap("image.bmp", NULL);
	BITMAP *buffer;
	buffer = create_bitmap(640,480);
	int my_pic_x = 0;
	int my_pic_y = 0;
	while(!key[KEY_ESC])
	{
		while(speed_counter > 0)
		{
			if(key[KEY_RIGHT])
			{
			my_pic_x++;
			}
			else if(key[KEY_LEFT])
			{
			my_pic_x--;
			}
			else if(key[KEY_UP])
			{
			my_pic_y--; 
			}
			else if(key[KEY_DOWN])
			{
			my_pic_y++;
			}
			speed_counter--;
		}
		draw_sprite(buffer, my_pic, my_pic_x, my_pic_y);
		blit(buffer, screen, 0,0,0,0,640,480);
		clear_bitmap(buffer);
	}
	destroy_bitmap(my_pic);
	destroy_bitmap(buffer);
	return 0;
}
END_OF_MAIN();
void increment_speed_counter()
{
	speed_counter++;
}
END_OF_FUNCTION(increment_speed_counter);
This is the main.cpp file.
The file "image.bmp" DOES exist, but nothing shows up. Just blackness...

Whats wrong?
I'am not quite sure about allegro since I haven't used it in a while, but I think the drawing and all should be done before searching for the input. Basically blitting before Pressing keys =).
hamik is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 07-30-2006, 09:44 PM   #5 (permalink)
naruto1327
Dante’s Inferno
 
naruto1327's Avatar
 
Join Date: May 2006
Location: California
Posts: 617
Reputation: 10
Send a message via AIM to naruto1327 Send a message via MSN to naruto1327 Send a message via Yahoo to naruto1327
MMOFaces Profile: None Yet
Default

Actually this is an example program from one of the tutorial sites.

I'll try doing that.
naruto1327 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 10:57 PM.

Forums Section List
Main Category Free Games Online Games Upcoming Games Online Games Upcoming Games
General Free MMORPG Fiesta Online    Maple Story Guides Trickster DOMO - Dream of Mirror Online
RolePlaying Free MMO & MMOFPS Conquer Online    Maple Story Buy/Sell/Trade WarRock Online Seal Online
Newbie Zone Korean/Foreign Games DragonGem Lunia World of Warcraft Age of Armor
  Browser/MUDs FlyFF Ragnarok Online Other Games Exteel
  Single Player RPGs Ghost Online Rakion    Rappelz Infinity
  Free MMORPG Requests Guildwars Runescape    Final Fantasy XI Cabal Online
    Gunz Online Scions of Fate (YulGang)    Goonzu Online Granado Espada
    Maple Story Silkroad    Gunbound Nostale



Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8
Onrpg, Copyright ©2003-2007, BlueCastle Media

Copyright © 2004-2007 BlueCastle Media