Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Creating a 2D platformer engine

  • 25-05-2013 01:27PM
    #1
    Moderators, Category Moderators, Computer Games Moderators Posts: 53,946 CMod ✭✭✭✭


    So I'm thinking about making a 2D platformer engine and I just need a little help in the logic involved. It's going to be smooth scrolling and tile based.

    What I'm getting is that for each step in the program I should be checking an array of all created objects, including the platform tiles, for collisions with the players bounding box. Now as these tiles are moved off screen they will be deleted out of memory and the array will need to be updated while new tiles will be created and added to the array.

    Am I going about this the right way, seems like an awful lot of collision checks to make and also how do I go about updating the array of objects that are in paly as they say?


Comments

  • Registered Users, Registered Users 2 Posts: 7,813 ✭✭✭TPD


    I haven't made an engine in code, so bear with me. If it's tile based, couldn't you keep a reference to each tile in a 2d array, then only check collisions with the tiles in a one or two tile area around the player?


  • Registered Users, Registered Users 2 Posts: 3,945 ✭✭✭Anima


    You could use Box2D to manage that for you no?


  • Moderators, Category Moderators, Computer Games Moderators Posts: 53,946 CMod ✭✭✭✭Retr0gamer


    I'm trying to avoid box2D. I find it really slow and it has some annoying quirks in Corona.


  • Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭satchmo


    Sounds like a good candidate for a quadtree or other similar hierarchical space partitioning structure. Quite simple to implement and will reduce the number of object/tile intersection tests by an order or magnitude. Since it's tile-based it should be even easier, as you wouldn't have to deal with tiles straddling borders and belonging to more than one cell.


  • Registered Users, Registered Users 2 Posts: 3 paulmcgg




  • Advertisement
  • Moderators, Category Moderators, Computer Games Moderators Posts: 53,946 CMod ✭✭✭✭Retr0gamer


    Thanks, going to have a look at these today.


Advertisement