Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
manage objects automatically
#3
Alright, I've attached an example Smile

I did not base it on the code you provided, easier to start from scratch.

In this example all sprites are manager by a "sprite manager". Sprites can access other sprites through the sprite manager. So, for example, player bullet sprites can get a list of all enemies from the sprite manager and do collision tests. Any sprite can remove itself or any other sprite through the sprite manager.

There's some oop style programming involved when it comes to sprites. The GreenEnemy inherits functions and data from Enemy, and Enemy inherits stuff from Sprite (the base "class").

I hope this helps! Just ask if anything is unclear Smile

And I hope that any "traditional basic programmer" looking at the code isn't scared off by all of this. I personally believe that oop and splitting your code into multiple files is "overkill" for most simple games. But when a game grows, it can certainly be useful. Use n7 however you want Big Grin

Edit: I also attached the sprite sheet generated by the Image Creator from Microsoft Bing. I picked four sprites from that one. It's an extremely handy tool that prevents me from giving up on so many projects Smile


Attached Files Thumbnail(s)
   

.zip   oop_shooter.zip (Size: 438.11 KB / Downloads: 7)
Reply


Messages In This Thread
manage objects automatically - by aliensoldier - 11-11-2023, 07:01 PM
RE: manage objects automatically - by Marcus - 11-11-2023, 09:46 PM
RE: manage objects automatically - by Marcus - 11-12-2023, 09:10 AM
RE: manage objects automatically - by Marcus - 11-13-2023, 02:57 PM
RE: manage objects automatically - by Marcus - 11-14-2023, 04:30 PM
RE: manage objects automatically - by Marcus - 11-16-2023, 04:13 PM
RE: manage objects automatically - by Marcus - 11-14-2023, 07:47 PM
RE: manage objects automatically - by Marcus - 12-09-2023, 09:28 PM
RE: manage objects automatically - by Marcus - 12-18-2023, 04:08 PM
RE: manage objects automatically - by Marcus - 12-18-2023, 05:11 PM
RE: manage objects automatically - by Marcus - 01-18-2024, 04:49 PM

Forum Jump:


Users browsing this thread: 3 Guest(s)