Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

How to use the Map (x, y) grid to reduce lag producing touch events

Touch events.  We all use them for area transitions and as triggers for cut scenes and what not, but as a map grows so does the number of these little insubstantial objects that the program must keep track of.  Too many and we get laggy gameplay which can be annoying if not utterly frustrating.  This tutorial is meant to discuss a strategy of reducing the number of these touch events by using the map grid point numbers as conditionals on one governing parallel process.  Thereby reducing what could be thirty or forty touch events to one parallel process event that does all of the work with far less lag.

Here's an example of an over evented map with lag. 
http://www.box.net/index.php?rm=box_v2_ ... _133909819

On this map there are 100 + touch events used to cover all of the edges so that the player will transfer back towards the center of the map with each touch.  The result is lag, and we don't even have anything on here worth looking at or playing through.  The question becomes how can we fix it.

Here's now the same map with only one parallel process achieving the same results.
http://www.box.net/index.php?rm=box_v2_ ... _133909975

No lag at all, but I still have a wide range of map points that transfer me back to the center of the map.  All the same work as the first map, but with only one event.

How to do this
It's actually quite simple.  First we need to set up a parallel process event. Then do the following on the event screen:

Declare variables.
Code:
Control Variables: [001: Player X] == Player's Map X
Control Variables: [002: Player Y] == Player's Map Y

Those two commands will constantly update those two variables to be equal to wherever you move the player on the map. 

Now to do something with them by adding the controlling conditionals (do not use the else handler):
Code:
Conditional Branch:: Variable [Player X] == 0
Conditional Branch:: Variable [Player Y] >= 1
Conditional Branch:: Variable [Player Y] <= 38
Transfer Player: [001;map001], (11,8)
Branch End
Branch End
Branch End
So, what does that mean?  Well the three conditions are working together.  It is only when the variable Player X is equal to zero and player y is between 1 and 38 that the area transfer will happen.  Conditionals could be used to make narrow lines of event as well as cubic regions or one simple grid point.  This approach can be easily used to replace most area transition events and cut scene triggers.  All while reducing the amount of events that produce lag on the system.
 

___

Sponsor

Wow that's a great idea, and can be used with Appoint By Variable in Transfer to get them to fit up the edges of the maps too.  Thanks!
 
An issue to consider when using this as a solution to consilidate events, complexity matters.  The bigger the parallel process is as far as coding is concerned the more memory it will eat up.  If its as simple as the method above it will do you wonders for efficiency.  However if it complex and filled with pages worth of conditionals you may be better off with the simpler lightweight touch events.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top