playMaker

Author Topic: draw ammo on screen  (Read 1931 times)

greg

  • Junior Playmaker
  • **
  • Posts: 68
    • View Profile
draw ammo on screen
« on: May 17, 2013, 09:09:50 AM »
I want to draw bullet images on screen for each bullet the player has.

I think i need to loop through the ammo count and for each bullet add a "draw gui texture", incrementing the position as well (so the bullets are drawn in a line).. not sure how to go about this in playmaker.

Andrew.Lukasik

  • Full Member
  • ***
  • Posts: 134
    • View Profile
    • my twitter @andrewlukasik
Re: draw ammo on screen
« Reply #1 on: May 18, 2013, 04:39:49 AM »
 Hi. For features requiring high frequency updates better stay away from making loops. You need algorithm that will reduce it to simplest/shortest/pre-computed process possible.
 If max ammo count is small, like 8 for example. Then fastest (for cpu) solution is to just make Integer Changed > Integer Switch > gui states that draw those situations.
 Well if max ammo is higher then you need something different but still simple.
« Last Edit: May 18, 2013, 05:13:43 AM by Andrew_Raphael_Lukasik »

izzycoding

  • Playmaker Newbie
  • *
  • Posts: 29
    • View Profile
Re: draw ammo on screen
« Reply #2 on: May 19, 2013, 06:57:55 AM »
Hey,

I agree with Andrew_Raphael_Lukasik.
Usualy for something like that there will be a max amount.
I use something similar for lives in my game. I have an empty GameObject that has an FSM on it. That then has child GameObject's for each of the textures (Life). The FSM is basicaly a manager for that display. I have 2 global events (one to add and another to subtract). This these then add or subtract 1 from a currentCount, then pass off to an "UpdateDisplay" state that does an IntClamp, followed by and IntSwitch. this then passes off to states that set up each of the textures by setting the Enabled value on the GameObject.

I have attached an example of the FSM I currently use. (I am in the middle of rewriting it to be a bit more dynamic and to use arrays of all the "Life" textures.

Hope this helps?

Regards,
 

Bqlqzs

  • Junior Playmaker
  • **
  • Posts: 52
    • View Profile
Re: draw ammo on screen
« Reply #3 on: July 10, 2013, 12:36:33 PM »
Hi

I think I have a very easy idea for this.
Create a long strip image with ammo icons
put this on a gui texture and move this...

Example:
- If full ammo, the texture left pose varriable is 0, so you can see all bullets
- When the ammo run out, you simple move the image out of screen
example left: -1 .... -2

just set the left varriable for the bullets width..

it is work if you want the panel at left or right side, but you can do this with vertical image at top or bottom..

sorry for my english :D I hope you understand this