sgtwombatstudios's Recent Forum Activity

  • I cannot download your capx at the moment, but I will try to solve your problem. I will pretend your array is called DialogArray. To get the array to work, I would first set your array to a size of (number of dialogs you want, 2, 1) on the start of the layout. In the first dimension of the array, I will store whether or not this piece of dialog has already been used, and the second dimension will be used for the text itself. Create a global variable called NumberOfDialogsUsed (or whatever you want to call it) and leave it set to 0.

    I am assuming you have some variable which stores the location in the array that you want to display, and I will pretend it's called PickedDialog.

    When you want to pick a dialog:

    If NumberOfDialogsUsed < DialogArray.Width | PickedDialog = floor(random(DialogArray.Width))

           (subevent)

           While

           DialogArray.At(PickedDialog) = 1 | Add 1 to PickedDialog

                  

                  (subevent)

                  If PickedDialog > or = DialogArray.Width | Set PickedDialog = 0

           (subevent)

           (no conditions) | Add 1 to NumberOfDialogsUsed

                            | Set DialogArray.At(PickedDialog) = 1

    Now to display your text, you will find it at DialogArray.At(PickedDialog, 1)

    In this example, once you used up every dialog, nothing will happen when you want to display text. At this point if you would like to pick from all the dialogs again, you will have to set NumberOfDialogsUsed = 0, and loop through your array and set DialogArray.At(loopindex) = 0

  • I haven't tried this before, but give your pathfiding objects the solid behavior, and then once every few ticks regenerate the obstacle map. I'm not positive if each pathfinding object needs to regenerate the map, or if this map is shared by all objects who are pathfinding. If the objects still collide or even clip each other every so often, then experiment with making the cell size and/or cell border bigger.

  • Yes, that's a great idea! I think that would be pretty easy, although if there were a lot of grenades, I don't know if the physics would slow down the game.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • For the following to make sense, I created two global variables called GameWidth and GameHeight in my project.

    At the start of a layout I set GameHeight = ViewportBottom(0) - ViewportTop(0), and GameWidth = ViewportRight(0) - ViewportLeft(0).

    The following is assuming that the grenade sprite width is the same as its height

    Give the grenade variables called MaxSize, MinSize, Peaked, and BouncesRemaining. (You can always change these to names that make more sense to you. All of these are Number, except for Peaked which is a Boolean)

    When you spawn a grenade:

    Set Grenade.MaxSize = GameHeight * 0.4 (play around with this value to get it the size you want)

    Set Grenade.MinSize = GameHeight * 0.1 (again, whatever value works for you)

    Now, I'm guessing that the size the grenade will start at will be a little bigger than when it hits the ground.

    So, set Grenade.Height = Grenade.MinSize * 1.2

    Set Grenade.Width = Grenade.Height

    Make an event:

    For Each Grenade                                      | Rotate Grenade Clockwise (or counter clockwise) 500 * dt

    If Grenade.RemainingBounces > 0             (you can try other numbers instead of 500)

                  

           | (subevent)

           |   If Peaked = False | Set Grenade.Height = Grenade.Height + ((Grenade.MaxSize - Grenade.Height) * dt * 300)

                                 (300 might be too little or too big, so try different values)

                                     | Set Grenade.Width = Grenade.Height

                      |   (subevent)

                      |   If Grenade.Height > Grenade.MaxSize * 0.99 | Set Peaked = True (if you

                                                             find that the grenade spends too much

                                                             time at its peak, try another number

                                                             like 0.97 or 0.95 instead)

           | (subevent)

           |   Else                 | Set Grenade.Height = Grenade.Height - ((Grenade.MaxSize - Grenade.Height) * dt * 300)

                                    | Set Grenade.Width = Grenade.Height

         

                      |   (subevent)

                      |   If Grenade.Height < Grenade.MinSize * 0.01 | Subtract 1 from Grenade.RemainingBounces

                                                                                                            | Set Grenade.Peaked to False

                                                                                                            | Set Grenade.MaxSize to Grenade.MaxSize * 0.5

                                                                                                             (play around with this number, such as 0.4, 0.3, etc.)

                                 |   (subevent)

                                 |   If Grenade.RemainingBounces < 1 | (The grenade is done bouncing, so you could either

                                                                                                         make it explode here, or it just stops)

                                       

    Let me know how this works out for you

  • I would give each enemy four variables, OldX, OldY, XDirection, YDirection.

    When an enemy is spawned and positioned, set Enemy.OldX = Enemy.X and Enemy.OldY = Enemy.Y

    For Each Enemy | Enemy.XDirection = Enemy.X - Enemy.OldX

                               | Enemy.YDirection = Enemy.Y - Enemy.OldY

                      (subevent)

                      If Enemy.XDirection = 0 | (here you would display the enemy standing still)

                      If Enemy.YDirection = 0

                      (subevent)

                      Else

                                 (subevent)

                                 If Enemy.XDirection < 0 | (face the enemy to the left)

                                 (subevent)

                                 Else

                                 If Enemy.XDirection > 0 | (face enemy to the right)

                                 (subevent)

                                 Else

                                 If Enemy.YDirection < 0 | (face enemy up)

                                 (subevent)

                                 Else                                | (face enemy down)

                     (subevent)

                     Enemy.OldX = Enemy.X   

                     Enemy.OldY = Enemy.Y

    This will check every enemy every tick, so it may slow your game down. If it does, you could stagger

    the enemies so it takes 3 or more ticks to check the direction of all the enemies, rather than all of them

    in 1 tick. Let me know if you would need help doing that.

    Also, if you wouldn't need to use Enemy.XDirection or Enemy.YDirection anywhere else in the game, you could make them local variables above the For Each event, rather than each Enemy holding their own copy of the variable.

  • Take a look at my game: http://balloonwarsgame.com. Playing the first level will give you some idea of how it works, specifically the water balloons. If you see anything you want to happen similar to the balloons for your grenades, let me know. I am actually working on changing the balloons arc to be shorter the closer you throw it, and bigger for the further away you throw it. Whatever you might want to know, I will tell you what I did to make it happen.

  • After writing that, I realized I missed something very important, you want blocks to attach horizontally as well as vertically. I will get back to you later with an example using the Pin behavior.

  • I don't know what the best possible solution is, but I can tell you what I would do if I were making this type of game.

    I would have an array called ColumnCounter where each index corresponds to a column. Index 0 would refer to column 0, index 1 would refer to column 1, etc. So its size would be how many columns you have in your game. The value held at each index would simply be a counter which increases by 1 every time a block in that column is spawned.

    Each block would have a variable called ID or something similar. It would be assigned the value at its column index in the array. After it is assigned, the value at the index would increase by 1. Each block would also have a variable called Column, and when a block is spawned, this variable would assigned the value of what column the block is spawned in. So if it spawned in column 5, its Column variable would be 5.

    When a block is destroyed, an event would perform a For Each search for Blocks. The next condition would be blocks whose Column variable matches that of the block that was destroyed. And the last condition would be blocks whose ID is less than the ID of the block that was destroyed. Each block should also have a variable perhaps called Detached or Free, or anything that helps you know that this block should fall. In the action part of this event, set your Detached variable to True. (You can make this variable a boolean. I don't use booleans though, I make two global variables, True = 1, and False = 0. I would make Detached a Number variable and type True and False. I do this to use booleans in equations.)

    In your event which advances the blocks, you would apply an additional Y movement to all blocks whose Detached variable is True. You may also want another variable which would prevent the detached blocks from being destroyed by a block that you launch.

    Wow, okay this post is long! I will step through this with an example to show you how it would work. I will make a variable called RandomColumn for randomly spawning a block. I will also make two variables called DestroyedBlockColumn and DestroyedBlockID

    • Block is spawned in column RandomColumn
    • Its Column variable is set to RandomColumn
    • It's ID is set to ColumnCounter.At(RandomColumn)
    • ColumnCounter.At(RandomColumn) = ColumnCounter.At(RandomColumn) + 1

    When a block is destroyed:

    • Block is destroyed

           - DestroyedBlockColumn = Block.Column

           - DestroyedBlockID = Block.ID

    • For Each Block, where Block.Column = DestroyedBlockColumn, and Block.ID < DestroyedBlockID

           - Set Block.Detached = True

    In your event which advances the blocks:

    • Block.Y = Block.Y + (whatever you have the normal blocks doing) + (Block.Detached * dt * (another number, perhaps a percentage of the game window height, you will have to experiment))

           - this part works if Detached is a Number variable

    I hope this helps, ask me any questions you may have.

  • In the event where you trigger the wave, you are going to add another action. Go to System, and then Set Value. For the variable, choose your timer variable, and then for the value, you would enter 20. If you have your timer set up so that it is constantly counting down, this should be all you need to do.

    Based on the information you provided, I think this should work, but if it doesn't, let me know more about how you set up your events.

  • Here's something to try, I haven't tested it though. Unless it is absolutely necessary for you to store the location of every enemy for other reasons, this might be a simpler solution.

    Pick a random destination, and use Pick Overlapping Point to check if any enemies are located there. Then do a value comparison: if Enemy.PickedCount is equal to zero. If this is true, then the enemy can travel to the destination.

    I would not use this in a while loop. When you are ready for an enemy to travel, you could check a for a free destination once each tick, or even check 3-5 times per tick with a for loop.

    I just thought of something, if Pick Overlapping Point does not pick any enemies, I don't know if Enemy.PickedCount will equal zero, since maybe you can't reference Enemy without any actually picked. If my first suggestion doesn't work, try this: do not check if Enemy.PickedCount is equal to zero. Create a local variable, (could be called PickedCount if you want). After using Pick Overlapping Point, use a For Each loop for Enemy. In the action, Add 1 to your local variable PickedCount. In a subevent, do a value comparison: if PickedCount is equal to zero.

    I hope this helps!

  • Hey, you may remember posting in my thread recently about this very same thing. Here's a couple of new things I found. First there's this, which says something about SYSTEM_ALERT_WINDOW allowing a window to keep displayed on top. Second, there's this, which talks about reading logcat. I don't know a whole lot about logcat, but if reading it could be implemented in a plug-in for C2, then we can get somewhere with this :)

  • I haven't tried this yet, but this is exactly what I was looking for! Xam, I don't know if you already figured it out/stopped trying, but here's what I do for a picture already taken (Note: this only works if the picture is taken with the app you are making.) When the picture is taken, I also save the URI in WebStorage. You set a local key (ex: "Picture" & PictureCounter ...or whatever string you want to create) with the value of UserMedia.SnapshotURL.

    (This part is an educated guess, as I haven't done this next step)

    When you later want to upload the picture, in the AJAX action, replace UserMedia.SnapshotURL with WebStorage.LocalValue("Picture" & PictureCounter) or with whatever your string is.

    If you want to upload a picture taken with the phone's own camera app, I do not know how to do that yet, sorry.

sgtwombatstudios's avatar

sgtwombatstudios

Member since 22 Jan, 2012

None one is following sgtwombatstudios yet!

Connect with sgtwombatstudios

Trophy Case

  • 12-Year Club
  • RTFM Read the fabulous manual
  • Email Verified

Progress

14/44
How to earn trophies