Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4036730
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:15:33+00:00 2026-05-20T12:15:33+00:00

I enjoy making games and now for the first time try myself out on

  • 0

I enjoy making games and now for the first time try myself out on mobile devices. There, performance is of course a much bigger issue than on a nice PC and I find myself particularly struggling with weapon (or rather projectile) class design.
They need to be updated a lot, get destroyed/created a lot and generally require much updating.

At the moment I do it the obvious way, I create a projectile object each time I fire and destroy it on impact. Every frame all active projectiles get checked for collision with other objects.
Both steps seem like they could definitely need improvement. Are there common ways on how to handle such objects effectively?

In general I am looking for advice on how to do clean and performant class design, my googling skills were weak on this one so far.

I will gladly take any advice on this subject.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T12:15:34+00:00Added an answer on May 20, 2026 at 12:15 pm

    I don’t think this is about class design. Your classes are fine; it’s the algorithms that need work.

    They need to be updated a lot, get destroyed/created a lot and generally require much updating.

    Instead of destroying every projectile, consider putting it into a dead projectile list. Then, when you need to create a new one, instead of allocating a fresh object, pull one from the the dead-list and reinitialise it. This is often quicker as you save on memory management calls.

    As for updating, you need to update everything that changes – there’s no way around that really.

    Every frame all active projectiles get checked for collision with other objects.

    Firstly – if you check every object against every other then each pair of objects gets compared twice. You can get away with half that number of checks by only comparing the objects that come later in the update list.

    #Bad
    for obj1 in all_objects:
        for obj2 in all_objects:
            if obj1 hit obj2:
                resolve_collision
    
    #Good
    for obj1 in all_objects:
        for obj2 in all_objects_after_obj1:
            if obj1 hit obj2:
                resolve_collision
    

    How to implement ‘all_objects_after_obj1’ is language specific, but if you have an array or other random access structure holding your objects, you can just start the indexing from 1 after obj1.

    Secondly, the hit check itself can be slow. Make sure you’re not performing complex mathematics to check the collision when a simpler option would do. And if the world is big, a spatial database scheme can help, eg. a grid map or quadtree, to cut down the number of objects to check potential collisions against. But that is often awkward and a lot of work for little gain in a small game.

    Both steps seem like they could definitely need improvement.

    They only ‘seem’? Profile the app and see where the slow parts are. It’s rarely a good idea to guess at performance, because modern languages and hardware can be surprising.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I may be in the minority here, but I very much enjoy Perl's formats
Is there any software out there that assists in creating an intranet-style proxy for
I have been searching for the perfect web development IDE for some time now.
I very much enjoy working in Notepad++, but I haven't yet found a plugin
I enjoy programming, usually. Tedious stuff is easy to get done as quickly and
I enjoy developing algorithms using the STL, however, I have this recurring problem where
I am not a mathematician. I enjoy a good math puzzle, but I admit
I'm a complete Xcode/Objective-C/Cocoa newbie but I'm learning fast and really starting to enjoy
I use both ruby on rails and Java. I really enjoy using migrations when
I was wondering if there were any dependency injection frameworks for use with development

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.