Jump to content


Photo
* * * * - 1 votes

Combining solid instances into 1


  • Please log in to reply
13 replies to this topic

#1 loverock125

loverock125

    GMC Member

  • GMC Member
  • 1616 posts
  • Version:GM8

Posted 19 October 2011 - 05:28 PM

  • Title: Simple Instance Combining
  • Description: An example demonstrating a way to improve performance in games with solid instances by combining them into 1.
  • GM Version: :GM81:
  • Registered: Yes
  • File Type: .gmk
  • File Size: 828 KB
  • File Link: Download Here
  • Required Extensions: None
  • Required DLLs: None
Summary
In most simple platform or even top-down games we have a simple solid object (e.g a wall) and place instances of it all over the room.
This can result in a big number of instances in your game and therefore in a performance decrease. For example in a 1024x768 simple
platform game room there are usually around 100-200 of these instance (32x32 sprites). In this example I'm using a script to combine
all of these instances into 1.

Free to use in any of your games.

Search Tags
  • GMCTUTORIAL
  • GMCCOLLISION
  • GMCPERFORMANCE

Edited by icuurd12b42, 14 December 2011 - 12:02 AM.

  • 0

#2 StopThatGuy

StopThatGuy

    GMC Member

  • GMC Member
  • 637 posts

Posted 25 October 2011 - 01:51 AM

I was wondering if perhaps you could upload a .gmk version? I'm really interested in seeing how this works but I'm afraid I don't have GM8.1.
  • 0

#3 TheMusicDork

TheMusicDork

    GMC Member

  • GMC Member
  • 305 posts

Posted 27 October 2011 - 11:46 AM

Im afraid I don't have GM8 either.
But I made this example a while back and it should be helpful to you... I can't remember if I commented or not, but if you need explanation just ask =)
CheersTMD

edit: forgot link =P Download combine.gmk from Host-A
also. No loverock125, gm8 cannot open a gm8.1 file. Out of curiosity how did you achieve this? By drawing every object to a surface and making that surface into a mask for an object?

Edited by TheMusicDork, 27 October 2011 - 03:51 PM.

  • 0

#4 loverock125

loverock125

    GMC Member

  • GMC Member
  • 1616 posts
  • Version:GM8

Posted 27 October 2011 - 01:52 PM

I was wondering if perhaps you could upload a .gmk version? I'm really interested in seeing how this works but I'm afraid I don't have GM8.1.


I'm sorry but I don't have gm8 pro. Can't gm8 open gm8.1 projects?
  • 0

#5 Ruub

Ruub

    GMC Member

  • GMC Member
  • 427 posts
  • Version:GM:Studio

Posted 01 November 2011 - 11:52 PM

This is quite cool!

I would love to use this but I'm not fully understanding the code :c After a little tweeching (spelled how?) I might be able to give those fake walls
variables.. If it's even possible :o

for example; a tile that opens when you have a key, or even better, one that makes the player jump when upon it. orrrrr one that changes colour by code or animation.

cheers!
  • 0

#6 Brasonic

Brasonic

    GMC Member

  • New Member
  • 15 posts

Posted 02 November 2011 - 05:38 PM

Cool, it saves a lot cpu usage, unless your room is huge such as platformers
  • 0

#7 epicpiedude

epicpiedude

    Artist/GameDeveloper

  • GMC Member
  • 362 posts
  • Version:GM8

Posted 03 December 2011 - 07:22 PM

Um, when I got it, it generated an unexpected error...
  • 0

#8 loverock125

loverock125

    GMC Member

  • GMC Member
  • 1616 posts
  • Version:GM8

Posted 03 December 2011 - 07:50 PM

This is quite cool!

I would love to use this but I'm not fully understanding the code :c After a little tweeching (spelled how?) I might be able to give those fake walls
variables.. If it's even possible :o

for example; a tile that opens when you have a key, or even better, one that makes the player jump when upon it. orrrrr one that changes colour by code or animation.

cheers!


This example combines instances and returns the id of a new object. In that new object you are able to add any code you want. If you have a few objects that generate such events then don't combine them, use them as usual. If you have many objects that generate the same event, then combine their instances into a new object and add the code to the new object.


Cool, it saves a lot cpu usage, unless your room is huge such as platformers


I don't get your point there. It saves CPU even if your room is huge, such as platformers of course. Having a huge room with many instances would slow down the CPU A LOT actually.
Please elaborate.


Um, when I got it, it generated an unexpected error...


I'm not sure why you are getting that error. What GM version are you using? I can upload an .exe version if you want to test it on the .exe.

Edited by loverock125, 03 December 2011 - 07:50 PM.

  • 0

#9 epicpiedude

epicpiedude

    Artist/GameDeveloper

  • GMC Member
  • 362 posts
  • Version:GM8

Posted 03 December 2011 - 10:46 PM

I'm using 8.1. It also said something about an access error.
  • 0

#10 Fira

Fira

    God Bless You All

  • GMC Member
  • 1390 posts

Posted 04 December 2011 - 08:19 AM

Can such an example as you made be done in Lite or no?
  • 0

#11 turgon

turgon

    VP Studios

  • GMC Member
  • 397 posts

Posted 08 December 2011 - 02:44 PM

I'm not sure why you are getting that error. What GM version are you using? I can upload an .exe version if you want to test it on the .exe.

Yes, please upload the .exe. I got the 'unexpected error' as well, using GM 8.1.
  • 0

#12 Jax

Jax

    GMC Member

  • New Member
  • 232 posts

Posted 14 December 2011 - 05:07 PM

Very cool example! I altered it to check for a variable called static, and if it was false (dynamic) it wouldn't combine it. The only serious problem is that you have to create such a big surface, but if you had a huge room you could make it combine everything in a 512x512 area. Later you could even deactivate segments of the room if you are away to yield even more performance enhancements.
-Rock on! :skull:

~Jax
  • 0

#13 Rip

Rip

    GMC Member

  • New Member
  • 16 posts

Posted 16 December 2011 - 06:20 PM

That's cool. But i have two questions...

1. Can I give name to that new object? Or it always set by random (if combined objects is random count...)?
2. Distance_to_object() dont work with this? It's see square((

Edited by Rip, 16 December 2011 - 06:44 PM.

  • 0

#14 falconfetus8

falconfetus8

    GMC Member

  • GMC Member
  • 38 posts
  • Version:Unknown

Posted 16 February 2012 - 01:01 AM

This has been working flawlessly for a long time, but now I'm having issues with it. For some reason, when I change rooms, it seems to delete every instance of the solid. How can I fix this?
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users