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.


Messages - irri

Pages: [1] 2
1
Graphics / class MyPicture - Copying Image to Sprite...
« on: February 10, 2009, 05:01:30 pm »
I think you're using a copy constructor for the wrong reason here.

Quote from: "JeZ-l-Lee"
I am a beginner C++ coder...

I can see that. If you want to learn good C++ from the beginning, I can recommend you the C++ book by Sthepen Prata. I read it last summer, and I really learned a lot :-)
Quote from: "JeZ-l-Lee"
...and do not know how to properly call:
MyPicture(const MyPicture& Copy) : Image(Copy.Image), Sprite(Copy.Sprite)

You can't.
The constructor you have takes a object of another "MyPicture"-object as argument. How are you going to create the first object of the class if you have no other constructor?

The point of having a Copy Constructors (or Constructors with Deep Copying) is for copying the data pointers points to, and not the address the pointer is pointing at. And since you're not using any pointers or are allocating any memory you don't need such a constructor.

And what are your class really gonna do?? I mean, isn't it just easier if you'll:
sf::Image img;
img.LoadFromFile("bajs.png");
sf::Sprite spr;
spr.SetImage(img);

2
Hi!
Just a PROTIP: Save your images as png (or jpg) to save yourself (and others) from lousy low-color gifs.

3
General / Trying to center horizontally a String on screen...
« on: February 04, 2009, 09:13:47 pm »
Firstly, GetCenter returns a sf::Vector2f (i think), and therefore you can't divide it by 2.
and secondly, because it's a method you must include the (), otherwise you'll send the adress of the method

4
General discussions / Re: SFML 2.0
« on: January 31, 2009, 08:54:04 pm »
Quote from: "T.T.H."
Quote from: "Laurent"
- Batch system (particles, tilesets, static strings)

w00t!


w00t! :P
I'm looking fordward to the batch system really much!
Cause' I'm making a RPG game with tilegrid-based maps, and particle effects for spells :P

5
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

6
General / How to get it working with Ubuntu and Code::blocks.
« on: January 11, 2009, 07:47:13 pm »
Quote from: "Laurent"
Apparently you first need to read some Linux tutorials :D

The correct command for changing the current directory is "cd". You almost succeeded with "cd Desktop/sfml-1.4", but why did you use lowercase?
Code: [Select]
cd /Desktop/SFML-1.4
Then you can enter "make" and "sudo make install".


I think you got one slash too much :lol:
Code: [Select]
cd Desktop/SFML-1.4

7
Graphics / Does SFML batch render draw calls?
« on: January 06, 2009, 07:16:11 pm »
Hmm.. is this the same as I'm experiencing in my game ( http://www.sfml-dev.org/forum/viewtopic.php?t=830 )???
I call the draw-method at least around 140 times per frame. And it goes really slow on my laptop.

8
General / Access Violation at Program Close
« on: December 28, 2008, 01:24:49 pm »
Perhaps you use different versions of SFML. :?:

9
Graphics / Optimizing tile-grid drawing
« on: December 27, 2008, 10:59:42 pm »
Quote from: "heishe"
it doesnt matter how much % it takes away. just make sure your frames ps stay high.

Ok, well, they don't.  :?
It is the Draw-method which takes the FPS down. hmm..

10
General / Classes and SFML
« on: December 24, 2008, 01:10:00 pm »
Quote from: "beginner88"
Thank you both!
@irri: Ok, but I thought when I get a class, for example, CPlayer with all his attributes like Health, Amor, etc. that I could use the sf::Image, sf::Sprite function in my class, to keep everything together... of course this is just an easy example and I know that it is more difficult in a "real" game.

Yeah, of course. But wouldn't it be easier to "Window.Draw(myCSprite.string);" in the main loop, if the sf::String in your class is public?

or, if your sf::string i private:

sf::String & GetString() const
{
  return myString;
}

and then in the main loop Window.Draw(myCSprite.GetString());

they're just suggestions :P

11
General / Classes and SFML
« on: December 24, 2008, 12:05:53 pm »
Of course that is possible, but I don't see the point in doing so.
sf::Sprite, sf::Image and all those are already separate classes.

Oh, and one more thing
the sf::RenderWindow-parameter cannot be const
Code: [Select]
 void Render(sf::RenderWindow &Window) const
   {
      Window.Draw(string);
   }

12
Graphics / Optimizing tile-grid drawing
« on: December 24, 2008, 10:52:34 am »
Quote from: "jdindia"
Your code looks fine.  I'd check other parts of your program.  A few hundred tiles should get drawn quickly.


It is those lines of codes that makes the process work so hard.
If I remove the whole DrawTiles, the CPU goes down to 0-1 % on my laptop.

It seems that the sf::RenderWindow::Draw is the one who causes the bad performance.
Because if I remove all but the Draw-line the CPU is still around 50-80%.

Code: [Select]
void Tilegrid::DrawTiles(sf::RenderWindow & App, const Character & player)
{
for(int i=0; i<20; i++)
{
for(int j=0; j<20 j++)
{
// Draw main sprite
App.Draw(mySprite);
}
}
}

13
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

14
Graphics / Display only a part of a string
« on: December 20, 2008, 08:02:03 pm »
Hi!
What if you want to have a dialogue box where the text appears letter by letter, or fade in.
Which is the best way to accomplish that?

15
Graphics / Best way to "SCROLL" an overworld map?
« on: December 04, 2008, 11:23:54 pm »
Which is the best way to store the tiles?
I have a class which contains the sf::Sprite and some other variables.

Because when I move my player, lets say to the right, I want the most left column of Tiles to be erased and all the other columns shall be shifted one step left. And the the column farest to right shall be read in by my XML-map..

In what shall I store my Tiles?

Thanks

Pages: [1] 2