How do I make a game like Flood ?

0 favourites
  • 11 posts
From the Asset Store
20 high quality click sounds, ready to improve your game's UI instantly
  • Hello, I've done the tutorials and got a hang of this nice software. Now I want to try something "harder" .

    I want to make a Flood type game but I don't know where to start.

    Example 1: floodit.appspot.com

    Example 2: play.google.com/store/apps/details

    Where or how should I start ?

  • take a look at arrays. You could build an array of the gameboard.

    You can then check the neighbor field for there color.

    You could also find some inspiration in the FAQ section. I think you could borrow some ideas from the one called Tile "digging" type game

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Ok, I've followed this tutorial:

    <font color=blue>https://www.scirra.com/tutorials/307/arrays-for-beginners/page-3</font>

    It should do the following:

    • make an array of 25 elements (Width=5, Height=5)
    • give the value of each cell to 1 or 2
    • create a star object based of the value of the cell (1=RedStar, 2=BlueStar)

    What have I done wrong ? Here is the capx:

    <font color=blue>https://mega.co.nz/#!d5ZR1I7D!AXcNcmFIAS9Ivp7Ky-oNsnRJ0o5vgvWHHCMm0OmqNek</font>

  • ?

  • blackhornettechnologies.com/Construct2Stuff/StarMap_BHT.capx

    Thank you, I've found the solution to my problem here:

    <font color=blue>http://www.scirra.com/forum/random-number-between-2-values_topic46161.html</font>

    Basically the random() function generated non-rounded numbers like 1,23456

    Thanks, this was my fix before I saw your example.

    <img src="http://s13.postimg.org/mztw3byyf/Star_Fix.png" border="0" />

    Also, nice way to load and destroy at start the sprites (I've put them outside the screen, but your solution is better)

  • You may want to consider just using one sprite with four frames, instead of four separate sprites. Once you start doing more things, you'll probably end up using a Family anyway, to achieve the same thing, otherwise you are going to end up doing everything four times, for each separate sprite.

  • Thanks, I will use separate sprites.

    Now the "funny" part: How do I convert the following code (recursive function) in Construct 2 ?

    Pseudocode

    Flood-fill (node, target-color, replacement-color):
     1. If the color of node is not equal to target-color, return.
     2. Set the color of node to replacement-color.
     3. Perform Flood-fill (one step to the west of node, target-color, replacement-color).
        Perform Flood-fill (one step to the east of node, target-color, replacement-color).
        Perform Flood-fill (one step to the north of node, target-color, replacement-color).
        Perform Flood-fill (one step to the south of node, target-color, replacement-color).
     4. Return.

    Code

    replaceColor = 1 <font color=green>// select value when clicking on a color button (values 1 to 5)</font>
    
    private void FloodFill(Point node, Color targetColor, Color replaceColor)
        {
          <font color=green>//perform bounds checking X</font>
          if ((node.X >= CANVAS_SIZE) || (node.X < 0))
            return; <font color=green>//outside of bounds</font>
    
          <font color=green>//perform bounds checking Y</font>
          if ((node.Y >= CANVAS_SIZE) || (node.Y < 0))
            return; <font color=green>//ouside of bounds</font>
    
          <font color=green>//check to see if the node is the target color</font>
          if (pixels[node.X, node.Y].CellColor != targetColor)
            return; <font color=green>//return and do nothing</font>
          else
          {
            pixels[node.X, node.Y].CellColor = replaceColor;
    
            <font color=green>//recurse
            //try to fill one step to the right</font>
            FloodFill(new Point(node.X + 1, node.Y), targetColor, replaceColor);
            <font color=green>//try to fill one step to the left</font>
            FloodFill(new Point(node.X - 1, node.Y), targetColor, replaceColor);
            <font color=green>//try to fill one step to the north</font>
            FloodFill(new Point(node.X, node.Y - 1), targetColor, replaceColor);
            <font color=green>//try to fill one step to the south</font>
            FloodFill(new Point(node.X, node.Y + 1), targetColor, replaceColor);
    
            <font color=green>//exit method</font>
            return;
          }
        }

    Or is there a better implementation of the Flood fill algorithm from here:

    <font color=blue>http://www.codecodex.com/wiki/Implementing_the_flood_fill_algorithm</font>

    <font color=blue>http://en.wikipedia.org/wiki/Flood_fill</font>

  • Ok, I've found here a Flood fill example but I have trouble understanding it:

    <font color=blue>http://www.scirra.com/forum/in-something-enclosed-or-is-it-just-me_topic53841_post340661.html#340661</font>

    A little help ?

  • blackhornettechnologies.com/Construct2Stuff/FloodFillBasics.capx

    Thank you very much <img src="smileys/smiley4.gif" border="0" align="middle" /> This is exactly what I needed.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)