User Tag List

Results 1 to 2 of 2

Thread: How can I place the food in 20x20 cells randomly

  1. #1
    No Products Registered

    Join Date
    Aug 2012
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How can I place the food in 20x20 cells randomly

    Hi, guys! I am a Chinese user.
    Here I am making a snake game which has a free mode.
    When the snake eats the food. it will create a new food in the cells.
    I am facing with a question that is how to place the food(the apple) in 20x20 cells randomly.
    Now i am using the random function to generate. but sometime the food is out of the frame.

    [*]X of the food = (Random((640/20)-1)+1)*20-10[*]Y of the food = (Random((480/20)-1)+1)*20-10

    无标题.jpg

    Thanks anyway! If anyone can show me an example. I will appreciate.

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Apr 2007
    Location
    Australia
    Posts
    1,151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Place the fruit at x = 0 and y = 0 (or whatever the top left of your grid is), then do the expression

    Set fruit X to : fruit x + ((random (Frame Width)+1) / 20 * 20 )
    Set fruit Y to : fruit y + ((random (Frame Height)+1) / 20 * 20 )

    Make sure the hotspot of your fruit active is set the top left corner as well.

Similar Threads

  1. Replies: 7
    Last Post: 10th February 2014, 01:37 AM
  2. Hungry Mouse Hong Kong - So much food, so little time !!! Let's eat !!!
    By Johnny_SIR in forum iOS Released Games & Apps
    Replies: 0
    Last Post: 21st August 2013, 05:08 PM
  3. Place Object Randomly Within a Zone
    By Power2r in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 31st May 2011, 08:43 AM
  4. Food Objects
    By im2famous4u in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 8th March 2008, 12:45 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •