• Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By CPPapprentice
      Hi Forum,
      in terms of rendering a tiled game level, lets say the level is 3840x2208 pixels using 16x16 tiles. which method is recommended;
      method 1- draw the whole level, store it in a texture-object, and only render whats in view, each frame.
      method 2- on each frame, loop trough all tiles, and only draw and render it to the window if its in view.
       
      are both of these methods valid? is there other ways? i know method 1 is memory intensive  but method 2 is processing heavy.
      thanks in advance
    • By drago28
      I'm using construct 2 physics I have a working bike with everything setup and I'm able to do frontflip and backflip by adding angular velocity to the bike
      I want to increase score/ add points and display the "backflip / frontflip" text when the bike does it.
      so please help me I want to know the logic and how it's done.
      p.s. example about construct 2 is not necessary, just explain me how other games do it or anything else you have to share
      Thanks,
      Drago
    • By otgs17
      You have 12 hours to search for supplies, transportation or you can continue your journey.
      But as soon as night falls, you must find shelter, turn it into a fortress to stand against the hordes of monsters.
      Equip soldiers, use bonuses and do not forget to follow the energy level of your fighters. 
      In battle be useful to your transport, it would be nice to find a tank.
      Every day the number of monsters to get more, they mutate into stronger and more dangerous forms.
      https://play.google.com/store/apps/details?id=com.otgs.FortTD&hl=en
      https://itunes.apple.com/us/app/fortress-td/id1367094965?mt=8
      https://www.youtube.com/watch?v=QIkXPikiRqc





    • By Masson
      Name: Dodging Dots
      Category: Arcade/Casual
      Description:
      Come up with your own strategy. Collect myriads of dots and maneuver from the coming blocks. Beware! There gonna be lots of them!
      The minimalistic world will captivate you for a long time. Try out!
      Features:
      Use upgrades to improve your game experience 🎮 Increase the velocity 🏄 of the dots to avoid the avalanche of blocks. Or you can increase the number of falling boosters to break 💥 through it, the choice is yours! Nice color shades that change throughout the game Ongoing game. Original soundtrack 🎧 Integration with Google Play Games Compete with other players 🏆 18 achievements to warm up your interest 🔥 Simple control, play with one finger Google Play: https://play.google.com/store/apps/details?id=com.groovin.blocks.delicate.survive.gameplay
       
      Feel free to leave comments. We really interested in improving this product and appreciate your support.
    • By khawk
      Pong Challenge!
      Make a single player Pong, with a twist. 

       
      Game Requirements
      The game must have: Start screen Key to return to the start screen Score system AI Player Graphics at least for the UI and players Sound effects for ball and paddle and when a player scores A unique gameplay element that makes your Pong game stand out from others The actual gameplay must happen on a single screen (no camera translation) Art Requirements
      The game must be 2D The art must be your own Duration
      4 weeks - November 1, 2017 to November 30, 2017
      Submission
      Post on this thread your entries:
      Link to the executable (specifying the platform) Screenshots: if the screenshots are too big, post just a few, if they are small, you can post more, just don't take the entire space A small post-mortem in a GameDev.net Blog, with a link posted in this thread, is encouraged, where you can share what went right, what went wrong, or just share a nifty trick Source-code link is encouraged
  • Advertisement
  • Advertisement
Sign in to follow this  

Should I use tiles or a single large image for my games background

Recommended Posts

I'm working on a 2D top down game in Python with Pygame. I was wondering if it is better to use one large image for a background or individual images? My problem with individual images is when I want to update a portion of the display without updating the entire display. How can I get a subsurface of multiple tiles if the location I need to update is between two tiles? Do I use layered surfaces?

Share this post


Link to post
Share on other sites
Advertisement

Just update both tiles completely, or more general, expand area to update to tile boundaries, then update all tiles in the area.

The amount of work that you have to do for a full tile versus a partial tile is the same, except for some clipping perhaps, but that's hardly worth the effort on modern hardware.

Share this post


Link to post
Share on other sites

However, Pygame uses ancient technology so re-rendering the whole screen each time is sometimes not ideal.

I would advise moving to Pyglet which uses more OpenGL for rendering, which means that redrawing the whole screen each frame is simple and efficient - which makes this question redundant.

Share this post


Link to post
Share on other sites
On 7/4/2017 at 9:16 AM, Alberth said:

Just update both tiles completely, or more general, expand area to update to tile boundaries, then update all tiles in the area.

The amount of work that you have to do for a full tile versus a partial tile is the same, except for some clipping perhaps, but that's hardly worth the effort on modern hardware.

Is there a way to combine all tiles into one so I can do something like self.displaysurf.blit(self.background.subsurface(gameobject), gameobject_location). How do I subsurface multiple tiles? Right now I just get a subsurface of my background image at the gameobjects locations and of the gameobjects size.

 

On 7/4/2017 at 9:25 AM, Kylotan said:

However, Pygame uses ancient technology so re-rendering the whole screen each time is sometimes not ideal.

I would advise moving to Pyglet which uses more OpenGL for rendering, which means that redrawing the whole screen each frame is simple and efficient - which makes this question redundant.

I've heard of it and will definitely check it out in the future. Is Pyglet more difficult than Pygame? Is it just for graphics?

Edited by mrpeed

Share this post


Link to post
Share on other sites
2 hours ago, mrpeed said:

Is there a way to combine all tiles into one so I can do something like self.displaysurf.blit(self.background.subsurface(gameobject), gameobject_location).

In the simplest case, you have a surface for each type of tile, and one for each kind of game object.

Updating the screen is then first drawing all tiles that need to be updated, and then drawing the game object over them at the right position. That is, you always draw everything, even though the tiles never move. The reason is that if the game object moves, the old position needs to display a tile-part. At the new position, you need to show a game object where there was a tile before.

If you want to combine drawing the tile background and the game object by using a single "draw" call, you need a surface that contains both items, with the game object at exactly the right position. Let's assume a game object is always at the center of a tile. Event in that case, this is feasible only if you have a very limited number of background tiles, or you have a very limited number of game object graphics. You make new graphics, one for each combination of background tile and game object (and one for each background tile without a game object). At runtime you decide which combination applies for each tile, and then draw the correct combination. To give you an idea how fast this explodes, if you have 8 game objects, and 4 tile backgrounds, you need 8*4 + 4 = 36 different images, a whole lot more than 8 + 4 = 12 if you draw background tiles and game objects independently.

When the game object is not always at the center of the tile, but something more to the left and sometimes more to the right, or it has different images (eg one for holding a sword and one for holding a spear), or you can have several game objects at the same tiile (or partly on the tile), Each combination here counts as "new game object" in counting the number of needed images.

As you can see, trying to draw the tile and the game object together in one draw call can make life very complicated.

 

3 hours ago, mrpeed said:

How do I subsurface multiple tiles?

In the simplest case, you don't. Each surface contains a single background tile, and you make a separate draw call for each tile. If your tile background doesn't change, you can consider making one very large background image (composed of some or all tiles), and use that to draw the tile background. (Sort of making a picture containing (part-of or) the entire level in tile backgrounds.) While it's possible (afaik you can create a new surface, and copy existing surfaces into it), I have doubts whether it is useful. You do get fewer draw calls, so it should be faster. On the other hand, you typically only want to draw a small part of the display, and clipping is usually done in rectangles. So if your update does not have a rectangular shape, you either have to split the update (meaning more draw calls), or you update more than you have to.

 

3 hours ago, mrpeed said:

Is Pyglet more difficult than Pygame? Is it just for graphics?

It does seem to do more: https://pyglet.readthedocs.io/en/pyglet-1.2-maintenance/

The big change of course is using OpenGL directly, instead of indirectly. (I don't know what pygame version you use. The 'old' pygame uses SDL, which was created before GPUs were common, so it has no GPU support whatsoever. There are newer pygame versions that use SDL2 (which does know about GPUs, although I don't understand how good the support is). PyGlet (and a few others) don't try to be pygame compatible at all, and just do everything with GPUs (I think). The latter is what pretty much every game does nowadays. Even drawing the entire screen every frame is not a problem there.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Advertisement