Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - irri

Pages: [1]
1
General discussions / Handling Game Events? (quests etc.)
« on: January 17, 2009, 05:01:03 pm »
Hello there!
I'm making a classic RPG-game for a project in school and I have some questions about game events (quests, story and such).

Here's some videos to better understand what I'm asking for: http://PA.irri.se/

I want a simple system for handeling events.
for  example, when you speak to an NPC in town, he gives you a quest to get him some special key item, and when you have done that something happends e.g. a door opens.

another ting, for example if the player goes to a certain place in a certain time, an event will begin..

Is scripting the only way to accomplish this, and which scripting language do you recommend? And how do you implement it the easiest way??

Thanks
Philip Irri

2
Graphics / Optimizing tile-grid drawing
« on: December 23, 2008, 01:48:00 pm »
Hello!

I'm working on a tilebased game, 480x288px, each tile is 32x32 ==> 15x9 tiles = 135 tiles on screen at the same time.

On my computer (Intel Pentium Core2Duo 3.0 GHz) the process takes around 5-8 % of my CPU. (I'm running Ubuntu, if that makes any sense)

A few days ago I tried to run the application on my laptop (Intel Pentium M 1.3GHz, also Ubuntu) and then the process of the game took around 50-80 % of the CPU!

I came to the conclusion that my draw-code couldn't be very optimized.
I use only one sprite, and changes the image every draw-loop if it is needed.

Here is my Draw method:
Code: [Select]
void Tilegrid::DrawTiles(sf::RenderWindow & App, const Character & player)
{
// Calculate the tiles the player is within range, plus an extra offset
int extra_offset = 1;

int Xa = int( -0.5f+((float)player.GetPosition().x-(float)GameEngine::WINDOW_WIDTH/2)/(float)GameEngine::TILE_WIDTH ) -extra_offset;
int Xb = int( 0.5f+((float)player.GetPosition().x+(float)GameEngine::WINDOW_WIDTH/2)/(float)GameEngine::TILE_WIDTH ) +extra_offset;

int Ya = int( -0.5f+((float)player.GetPosition().y-(float)GameEngine::WINDOW_HEIGHT/2)/(float)GameEngine::TILE_HEIGHT ) -extra_offset;
int Yb = int( 0.5f+((float)player.GetPosition().y+(float)GameEngine::WINDOW_HEIGHT/2)/(float)GameEngine::TILE_HEIGHT ) +extra_offset;

// If the variables isn't in range, make them so.
(Xa < 0) ? Xa=0 : 0;
(Xb > gridsize.x) ? Xb=gridsize.x : 0;
(Ya < 0) ? Ya=0 : 0;
(Yb > gridsize.y) ? Yb=gridsize.y : 0;

int imgNr = -1;
for(int i=Xa; i<Xb; i++)
{
for(int j=Ya; j<Yb; j++)
{
// Set position
mySprite.SetPosition(i*GameEngine::TILE_WIDTH, j*GameEngine::TILE_HEIGHT);

// If a secondary img is available. Draw it underneath the main one.
if (grid[j][i].GetImage2() != -1)
{
mySprite.SetSubRect( grid[j][i].GetRect2() );
App.Draw(mySprite);
}

// new_imgNr is for optimizing.
// It don't have to re-GetRect if the same img was used last tile.
// This doesn't apply if a secondary image is used.
int new_imgNr = grid[j][i].GetImage();
if (imgNr != new_imgNr || grid[j][i].GetImage2() != -1)
{
imgNr = new_imgNr;
mySprite.SetSubRect( grid[j][i].GetRect() );
}

// Draw main sprite
App.Draw(mySprite);
}
}
}


It must be another way, more CPU friendly. Any ideas?

Thanks
Philip Irri

edit: oh, I just noticed there was another thread discussing this.. oh well

3
Graphics / Best way to "SCROLL" an overworld map?
« on: November 29, 2008, 05:55:13 pm »
Hello!
I'm making a RPG-game for a project in school. My overworld is a tilebased one as you can see in the image. Which way is the best to SMOOTHLY SCROLL the world when I move the player? When am I supposed to load the new images and sprites and so on?



Thanks
Philip Irri

Pages: [1]
anything