TomCarter's Forum Posts

  • Hello.

    A simple example of this would be "If the car is between X angles for 3 seconds, restart layout"

    If the car is only upside down for 2 seconds and manages to get back on it's wheels, do not restart layout.

    I feel like there is probably a very simple way to do this...

    Thanks.

  • round(random (1, 2)) was missing so its whole numbers so i dont get a 1.23 otherwise 1 isn't 1

    Hey, choose(1,2) will give you a 50% chance of both numbers and always an integer.

    round(1,2) will round down and not give exact chances you want.

    It's usually better to use choose for this kind of thing because of this

  • Thanks for both of your responses, you've cleared it up and gave a better compromise than the one I came up with.

    Cheers!

  • Hello people.

    Problem: I am not allowed to name an animation a simple number such as "1" or "34". It just reverts the name back to the previous one with no error message or reason why it doesn't work. I don't know if this is a bug or intended, I guess intended to stop certain stuff?

    I want to spawn random background objects in my side scrolling game. The way I have been doing this is using tons of events and sprites each individually looking something like "if level = 1, Every random(3,6) seconds create object cloud1" etc...

    Now I would like to make a big "BGobjects" sprite that contains tons of animations and frames for the various BG objects I need. I can simply name each animation 1 2 3 4... for each level they go into and do then the following:

    Every random(3,6) seconds create object BGobjects

    set BGobjects animation frame to Level (So on level 1, it will be all the level 1 objects, level 2 they'll all be level 2...)

    set BGObject frame to choose (1,2,3,4) for the 4 different kinds of clouds that fit into level 1. Or the 4 different kinds of bubbles that fit the underwater level 2. Etc.

    This would work seamlessly and use very few events, if only it allowed me to name the animations simple numbers in the first place...

    The only theoretical workaround I can think of but have not tried yet is to simply call the animations fitting names such as "Clouds" "Bubbles" and then simply add a global variable called "AnimationHelper" and 4 events like (Level = 1, set AnimationHelper to "Clouds") (Level = 2, set AnimationHelper to "Bubbles")

    And then just

    set BGobjects animation frame to AnimationHelper

    Same thing but a little more convoluted, should work though, right? Any better ideas? Any explanation on why I'm unable to name an animation a number? Thanks.

  • My solution to this wasn't exactly elegant but it works, I have 8 global variables all default value of 0.

    CommonLootDrop, uncommonLootDrop, rareLootDrop, epicLootDrop

    CommonLoot, uncommonLoot, rareLoot, epicLoot

    When a monster dies, roll to see if you got a drop from it. A weak rat for example would be set commonDrop to random (0,100) set uncommonDrop to random (0, 60)

    Then I have events such as "CommonLootDrop > 50, set CommonLoot to choose (1,2,3,4) and then another event that is CommonLoot = 1 + 1 health potion, if CommonLoot = 2, +10 gold, etc etc... Same for the other rarities.

    I have it so you only get 1 drop at most per kill, so I do the loot checks in order of rarest to least rare.

    As an example I kill a big enemy with random (0,60) epic. random(30,80) rare. random(50,100) uncommon.

    It would roll epic, check if over 50, roll rare, check if over 50, roll uncommon, check if over 50.

    So if those random numbers were 40, 65, 99, then it actually would stop at 65 and give me a rare item, never completing the uncommon roll as it's now irrelevant.

  • Depends a little on your random facts, you might as well just do a really simple thing, like: Set Text = choose("My first sentence","My second sentence","My third sentence","Well, this is getting LONG","But it does seem to take even more")

    No variables, no unnecessary setting of anything, easy to edit. As long as you don't have a million facts it seems quite suitable.

    oh MAN!

    Thanks this works perfectly and is literally the same thing but smoother. I totally over engineered this simple problem without thinking

  • Hi guys, I added a "random fact" area in one of my games just for some humorous stuff between levels to keep the player amused.

    The way I did it was thus:

    GlobalVariable: RandomFact = 0

    SpriteFont: RandomFact = "" (blank)

    On start of layout: Set RandomFact to choose(1,2,3,4,5,6,7,8,9)

    RandomFact = 1, set SpriteFont: RandomFact = "That fly looks pretty mad. I better not get in his way."

    RandomFact = 2, set SpriteFont: RandomFact = "Why is nobody else talking about the flying fish?"

    etc. etc.

    Every extra fact I want to add to the game I need an extra event to handle it. Pretty painful as on the free version I only have 100 events to work with.

    Any clever stuff involving arrays I could be using instead?

  • Thanks very much, that works great.

    I didn't know about "PickedCount"

    I guess it's time for me to re-read the manual, more carefully this time! Thanks again.

  • Since the oldest bullet would probably have either the lowest zorder or the lowest UID you could sort by either and pick the first object (Pick nth instance action) for example.

    Do you mind giving me an example?

    I still don't know how to destroy a specific bullet.

    I can use a global variable to count the bullets on screen and destroy if there are more than 4, but this destroys ALL bullets.

  • Hi guys,

    I have no idea how to do this (title).

    I also don't understand how I can refer to cloned objects in general (like 1 copy of a bullet, or one instance of an enemy)

    I know this will be super simple! Thanks!

  • Hi guys.

    I am creating an RPG style game that uses tilemaps for it's graphics. For example I have trees and rocks that the player cannot walk through, I have pokemon style grass that have a random chance of starting a battle when walked over, I have doors and entrances that act as links to new rooms/layouts.

    Right now I can do all of this easily and accurately by creating invisible sprites and placing them exactly over the relevant tiles, then tying the events to collision of the invisible sprites. The problem with this, of course, is that I actually have to keep creating and placing all these invisible sprites, this takes time and it would be easy for me to make mistakes, placing them incorrectly or forgetting to place them in places!

    So yes. It would be extremely useful if I could tie an event or behavior to each tile in the tilemap, following the above examples, I would make all tree tiles have a solid behavior so the player cannot enter that tile.

  • Hi guys, I'm fairly new to construct 2 and thinking of buying it pretty soon.

    I don't really want to put the money down until I think I have something worth investing in though.

    I intend on making a fairly deep RPG style game and will need potentially 1000s of events in total.

    I'm sure others have been in my position before and I'm curious how they handled it, I am thinking I can perhaps just make most layouts/event sheets work independently from each other for testing purposes, and I can pretty simply just join them together when needed, maybe with a few minor tweaks, but not so much effort.

    For example, I'd put the level up code all in 1 layout/event sheet, then all the pause mechanics into it's own separate file, etc... Is this practical? Is there a better way? Thanks.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • >@TomCarter : Sorry, my bad, that's not for the use inside construct 2.

    As an apology, I tuned your capx-file, as simple, as I would do it.. Maybe this helps you more than just with this specific problem

    Hey! Thank you!

    I'll admit I spent about 15 minutes staring at it screaming why isn't it working?! As of course what you're wrote is logically sound...

    The thing we both missed is that I start my levels with 1 bullet off screen that is instantly destroyed. This means that before the player fires anything, we get -1 projectile, which means we have 0 projectiles when we still 1 ammo left which causes the game to restart as soon as we fire that last projectile, rather than when it's destroyed like we want.

    Very simple fix of course, I simply made Projectiles start at 1 instead of 0. I also did some clean up stuff like having it be set to 1 when loading any layout so it works for the rest of the game, just mentioning this in case anyone else with the same problem reads this thread ion the future and is confused

    Thanks again for your help.

  • Hey, thanks for responding... I gotta admit I'm pretty clueless though.

    Searching for "sol.hasfunctions()" in Construct 2 brings me no results and googling it didn't really bring me anything I could understand.

    I understand what you mean, but I don't know how to actually use it in Construct 2!

    Could you be so kind to show or tell me practically how I can apply this to my specific problem?

  • Alright, I have attached the capx file to this comment.

    It's obviously a WIP and a bit of a mess, but just run any of the numbered layouts and you'll see how it works. There is only 1 event sheet currently.