Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Nausea

Member Since 25 Nov 2012
Offline Last Active Oct 26 2014 06:12 PM

Posts I've Made

In Topic: [SDL] map with animated tiles. performance question.

26 June 2013 - 07:21 AM

 

 
I have a render function in my map class that goes over the tile slots, if the current tile slot is inside the camera range, go through the list of tiles and check which ID it corresponds to and render the tileslot at x/y with the tiles sprite x/y. This render function is run inside the applications render function, when all the things in the program has been through the render function it blits it on to the screen.
 
Maybe my wording is poor. What i mean to say is that the maps rendering function blits the stuff on to the screen surface, later in the applications render function when everything in the program is blitted on to the screen surface i "flip" it.

Would be nice if you could reply to it so I know if I'm actually doing something wrong, which I don't think that I do.

A quick way to test if your framework has the problem is to write a simple stress test.

I'm not sure about it, but it sounds like you are filling the screen with small tiles. In my mind, that means you have perhaps 30x20 background tiles + 50 or so foreground tiles + 50 or so UI sprites, totaling about 700 or so sprites. So load up and draw 1,000 sprites in a frame for one test and perhaps 2,000 or even 5,000 sprites in a frame in a second test, doing the same thing you do to normally draw them. Those can even be copies of the same image, if that is how you intend to run it. Run it and look at performance.

It is not uncommon that drawing a tile-based world in the way you described -- drawing the tiles individually -- has difficulty in running at a high frame rate. Many times (but certainly not always) the simple implementations will run into problems because they are copying the sprites to video memory every frame. Using SDL objects correctly probably won't have the problem. The test is to just make sure you are using them correctly and your solution will work.

Running a quick stress test can easily verify that your intended method can or cannot handle that many individual draw calls.

 

 

From what I can tell my program takes up 0% in the task manager with a 1000 tiles drawn inside and outside the screen region.

I go through my tilelist, blit the tiles and then when all are blit I send it from the buffer to the screen in one go.

 

I might go for splitting the map up in sections just because of speed anyway, might not be needed but might be a good thing anyway.


In Topic: [SDL] map with animated tiles. performance question.

25 June 2013 - 02:43 PM

 


My worry is that this will be very taxing on the computer when I get to the point of making a full fledged map. Not to mention when I will have to in some way check for collisions with the tile slots.

How many do you have? Be realistic.

 

Rectangular collision tests are cheap. Performing even 1000 rectangular collision tests on your objects probably isn't going to be a noticeable blip on the profiler.

 

If you are running with multiple thousands of rectangular tests every frame, or hundreds of non-rectangular tests every frame, then it will make sense to use a spatial tree.  

 

If your numbers are small then don't bother with the added complexity.

 

 

Ok.

Well I won't be having over 1000 tongue.png

I guess I don't have to be worried, good to hear some thoughts on the subject tho.

 

Thanks

 

EDIT:

 

 

However...

 

The thing that concerns me MUCH more is that you are describing a situation where you are probably sending all the data from the CPU to the GPU every frame.

 

You implied but did not actually state how you intend to render it. Sending all the data to the GPU every time is incredibly inefficient and slow. Make sure you are using SDL methods and objects that move the content to the graphics system a single time.

 

 

Hmm.. I have a render function in my map class that goes over the tile slots, if the current tile slot is inside the camera range, go through the list of tiles and check which ID it corresponds to and render the tileslot at x/y with the tiles sprite x/y. This render function is run inside the applications render function, when all the things in the program has been through the render function it blits it on to the screen.

 

Maybe my wording is poor. What i mean to say is that the maps rendering function blits the stuff on to the screen surface, later in the applications render function when everything in the program is blitted on to the screen surface i "flip" it.


In Topic: [SDL] map with animated tiles. performance question.

25 June 2013 - 02:26 PM

Are all of your tiles the same size? If so, there are calculations you can perform based on the position of the camera and the dimensions of a tile, returning the element numbers of which tiles to draw (I could go into more detail if this is the case). If your tiles are not all the same size, then you might have to use a space partitioning method such as quadtrees.

The tiles are all the same size. 

 

However I mostly wonder if this will be a real bad solution?

 

I've tried to fill up the screen with tiles without feeling any real performance problems and I wonder if that will change when I have a full map even tho I will only draw the tiles inside the camera and the collision boxes will be fewer to check for.


In Topic: How on earth do I start a game?!

20 June 2013 - 07:42 AM

If you already know some basic c++ and feel somewhat comfortable in it you could go to sdltutorials.com for pretty in depth tutorials and it will get you started with SDL. 


In Topic: Programming a 2D spritesheet animation system

19 June 2013 - 03:17 PM

I am about to start working on a 2D animation system using spritesheets. Below are my plans for this system, but before I implement it I thought I would ask for some thoughts and opinions.

 

  • Not all frames in all animations are of the same size. I then map each frame to a rectangle with the size of the frame which will save me a few bytes of memory.
  • I plan to have an array of frame times to allow different frame time for each frame. Will make it easier to control the animation.

Good? Bad?

 

I am also curious about how to best implement some kind of achor point. A simple example, a guy is standing straight (thin and high frame), then falling over (wide and low frame). Using either of the corners as an anchor point, the "standard/default" way, would result in the guy not only falling over, but also moving sideways on the screen. To solve this the anchor point needs to be set to the feet. Right? If so, I will also need an array for the anchor point for each frame, where the anchor point will indicate how much to move the sprite up/down and left/right. Or?

 

Am I missing something? Better way of doing things?

 

I'm a noob but I guess I could tell you how I did this.

 

I used a Animation class to handle the animation itself. Then it had a list of Frameset class instances and a pointer to the current Frameset which it used to loop over it.

The Frameset class had a list of Frames and ability to add Frames etc. The Frame class had x/y cords for the image and offsets and some more stuff.

 

I hope you get the idea, some time ago since I coded it.

 

Maybe someone with actual skill can tell you how much my version sucks. :)


PARTNERS