Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Performance issues with 2000 sprites and 1000 lines

Author
Message
TCat87
17
Years of Service
User Offline
Joined: 27th Dec 2006
Location:
Posted: 10th Jan 2007 22:39
Does anyone have experience using a couple of thousand sprites in a DBPro program? How about a thousand or so lines to draw? What performance issues will I encounter with this number of things to render and how might I go about addressing them? The game I am programming can have as many as 271 tiles, each made up of 8 animated sprites. The playing area is overlay with a grid of about 1000 lines.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 10th Jan 2007 23:34
The first question is this: How many tiles will actually need to display at any time? You could have a world of several milion tiles, as long as your engine dicated that you would onlyever see 500 at one time.

Using a smaller number of visible tiles, whilst having data for a much larger playing area is a common technique. It's what's known as "Smoke and Mirrors". What the user perceives and what is actually happening ar 2 very different things

As far as drawing lines is concerned, it's not a wise move. The 2D drawing commands are slow. Try and devise a workaround, perhaps a single sprite with the grid-lines as a texture, overlaying the tiles.



RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 10th Jan 2007 23:48
To add to what Vink said;

Basically, you could have data showing the positions, rotations, actions, names, etc, for thousands of sprites in your program, but if you only ever see lets say 10 sprites, you can use a recycling system.

For example lets say you have 3 characters, those being an ogre, a wolf, and a wizard. Lets also say you only want to use 1 sprite at a time.

If you know, for a fact, that only 1 sprite will ever be on screen, then when 1 sprite leaves (lets say the ogre keaves), you could then change that sprite's image and necessary data to represent the wolf who is now entering the scene. You store data for each of the 3 characters, but you only need 1 sprite for all of them.

Take that onto a larger scale, you have 2000 ships flying around in a huge space battle, but only 20 are ever seen, you only need 20 sprites, not 2000.

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 11th Jan 2007 01:03 Edited at: 11th Jan 2007 01:08
One of the things that people tend to do a lot is think that tiles on the map need to be sprites. If the tile is a single image or even if it's an animated one you just paste images using the map array. You only want the sprites to be actual characters in the game and bullets/spears to attack those characters.

Edit: Instead of drawing the grid each time with "line" statements use one single image thats the grid and paste that on top of the tiles... or make your tiles smaller and skip a line between each tile.

Can we see a screenshot?
TCat87
17
Years of Service
User Offline
Joined: 27th Dec 2006
Location:
Posted: 11th Jan 2007 02:06
Thanks! I'll work on the grid overlay and texture ideas. There is a screen shot in the attached Word document taken from the Java version of the game. As you can see, all of the tiles are visible all the time; plus player tokens and action selectors. I'm using sprite animation to change colors on tile background, the colored radians, and the small hexagon in the tile center.

Attachments

Login to view attachments
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 11th Jan 2007 11:24 Edited at: 11th Jan 2007 11:28
You should read up on the Sim City development, and why they never took the route of doing a true 3D interface. It's quite relevant to what you are doing, as sprites are actually 3D components implemented in a stricter framework.

Their dev section (sorry, can't remember the link) explains the issues, technicalities and complications of creating a tile based world in a 3D environment.

You should also consider looking at image memblocks. Applying different "patterns" onto each tile would be quicker using memblocks, and also more fexible. There will be a slight learning curve, but a small number of functions now will make life easier for you in the long run.

I wrote two newsletter tutorials on image memblocks last year, have a look in the newsletter section for them.



Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 11th Jan 2007 12:29 Edited at: 11th Jan 2007 12:31
Wow that game looks pretty intense. I'd like to try that java version. Can you supply a link?
TCat87
17
Years of Service
User Offline
Joined: 27th Dec 2006
Location:
Posted: 11th Jan 2007 15:32
Grog, I am on my way out the door to be gone for a couple of days. I can E-mail you a copy after I get back. It's a 2 or 3 player game, and as of now, you need to be at your computer to play (or just play against yourself). Not a lot of polish, but certainly playable.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 11th Jan 2007 22:59
Cool
TCat87
17
Years of Service
User Offline
Joined: 27th Dec 2006
Location:
Posted: 13th Jan 2007 03:02
Grog, E-mail me at hexad.pastimes@yahoo.com and I will send you a copy of the game (it's called HEXERS).
TCat87
17
Years of Service
User Offline
Joined: 27th Dec 2006
Location:
Posted: 13th Jan 2007 03:34
Well, I figured out how to eliminate drawing most of the lines I thought I needed (I added them to the images I am using to show the radians of each tile). Now I just hope all those sprites draw quickly.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 13th Jan 2007 11:42
Quote: "Grog, E-mail me at hexad.pastimes@yahoo.com and I will send you a copy of the game (it's called HEXERS)."


Sent and thanks.

Quote: "Well, I figured out how to eliminate drawing most of the lines I thought I needed (I added them to the images I am using to show the radians of each tile). Now I just hope all those sprites draw quickly."


That's a good idea too. You may be able to still just use an array and paste all the images... gotta try the game first though.
TCat87
17
Years of Service
User Offline
Joined: 27th Dec 2006
Location:
Posted: 13th Jan 2007 17:37
Game mailed. Let me know if you have any problems.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 15th Jan 2007 05:10 Edited at: 15th Jan 2007 13:58
Ok I got it to work (never worked with .jar files before). It's a great game and cool concept.

After seeing how it worked I threw together this:



For ease of use each angle and each color must be a separate image. All images are pasted one at a time till all the angles are shown. Then the center image is pasted then the player itself. The array to store all the data only needs to store 7 numbers per hexagon. The numbers stored in the array are only 0, 1, 2, or 3 to represent the color used (the zero is only used for the absence of a player piece). Even though it sounds slow pasting that many images will be much faster than working with sprites.

I attached the image. I left all the hexagons so it's easier to see the angles... the proper way is to take out all the hexagons and only paste one. I could only take a screenshot and capture your graphics so the attached image has many flaws but it'll work for this example.

Attachments

Login to view attachments
TCat87
17
Years of Service
User Offline
Joined: 27th Dec 2006
Location:
Posted: 16th Jan 2007 00:00
Thanks Grog! I really appreciate your effort. I'll study your code and run some tests to see if I understand it. I may still play with sprites too, just to see what happens (it'll be good practice). Have fun playing HEXERS.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 16th Jan 2007 00:42
Np I can't wait to see the Darkbasic version.
TCat87
17
Years of Service
User Offline
Joined: 27th Dec 2006
Location:
Posted: 16th Jan 2007 03:01
Have patience! It took me a couple of years to do the Java version (it was my first Java program and my first time working with an OOP language). I hope to do a DBPro version quicker, since I have some of the concepts worked out already, but the approach is very different, even though the language is much easier.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 16th Jan 2007 11:01
Take your time and let me know if you need any help.

Login to post a reply

Server time is: 2024-09-25 15:27:43
Your offset time is: 2024-09-25 15:27:43