Lou Bagel's Forum Posts

  • Man you make it look easy :p Is there a way I can set it to buy only 10 instead of 10.2454578784?

    How long have you been using construct ?

    My profile says for just over a year—but I think it was a little longer than that. There is a ton I don't know but I just try to answer the questions in areas that I know.

    Did you use the floor()? Because floor(10.2454578784) = 10

    round() - rounds to nearest integer

    floor() - rounds down

    ceil() - rounds up

    Once you start learning the commonly used expressions and such it will start to snowball. These are a couple pages to visit often:

    https://www.scirra.com/manual/126/system-expressions

    https://www.scirra.com/tutorials/77/nat ... onstruct-2

    Then whenever you use something new to you visit the page in the manual so you know the conditions, actions, and expressions. Things that seem complicated may already be built in—you just have to know what is available

  • Edited — had a bunch of mistakes

  • math

    ...lol

    On Buy max button clicked

    --Add to "baby chick" floor(eggs/10) (eggs divided by price)

    --Subtract from "eggs" floor(eggs/10)*10

    Or (if they are sprites not variables)

    On Buy max button clicked

    -Repeat floor(eggs/10) times

    --Create chick

    --Subtract 10 from eggs

    Floor() simply rounds down. So if you had 95 eggs, floor(eggs/10) would result in 9 (9.5 rounded down)

    Edit: Whoops, had some stuff backwards

  • Global Variable "FireRate" initially set to 1

    Every "FireRate" seconds - create object

    Every 10 seconds - Subtract 0.02 from FireRate (or better yet) Set FireRate to FireRate*0.9

  • Are you talking about the quantity or speed?

    Either way you could make a global variable for the fire rate. Every x seconds alter the fire rate.

    Multiple ways to set this up—what is your event for creating the rain drops?

  • Worked like a charm. My brain stopped working and I only figured I could use numbers instead of other variables. Thank you very much sir.

    You are welcome. Any field like that you can use any variable or expression

  • Maybe try:

    Player is on screen (to pick the players that are on screen)

    -compare two numbers: picked count < player count

    --every tick set scale to layoutscale - 0.01 (or however fast you want it to zoom out)

    **off the top of my head—may not be foolproof

  • Now my problem is that even if i buy 10 chickens I am only still receiving 1 egg per second instead of 10.

    For this, right now you probably have "add 1 to eggs", where you clicked on "add to" and when the field popped up you left it as 1.

    Instead of adding 1 to eggs you want to add 1 egg per chicken, correct? So add the number of chickens to the number of eggs. If chickens is already a variable somewhere just put the variable in the field. If chickens are sprites then use the count expression which will count the number of instances in the project of chickens (so be wary of ones off the screen and such). Can't remember if the expression is chickens.count or count("chickens")...

  • Instead of adding 1 to egg add chicken 'count' to egg

  • So, can characters effect and/or be affected by a background tilemap? Like slow down characters going through mud? Or would I need to make sprites for that?

    You should be able to using:

    [quote:283teqi9]Tilemap conditions

    Compare tile at

    Compare the tile ID at a position in the tilemap.

    https://www.scirra.com/manual/172/tilemap

    Although, that could add in a lot of checks every tick

  • Okay, I think I get your situation. I can't look at your capx now but will try to tomorrow if you are still having problems.

    So I assume from this they are typing in the letters on the keyboard?

    One idea off the top of my head is instead of using a textbox to detect keyboard input and only do anything if it matches.

    Either way, I would probably start by loading the letters into an array.

    Create a variable that starts as false (boolean or 0)

    Loop for array.width

    -if [letter to check] = array(loopindex) set variable to true/1

    If variable = true/1 then update text/allow the letter to be added.

    If you let them type anything in the textbox then you would have to check it after and remove as opposed to allow. But you can do the same in a nested loop

    Loop for textboxt.length

    -Loop for array.width

    --if [letter to check] = array(loopindex) set variable to false and end loop

    Can't look at the capx right now so not sure what you have already and if this helps or not...

  • I agree it is a bit odd you can't have the for loop not execute but as blackhornet puts it is just a limitation to deal with. Construct being a 'no coding required' engine has the goal of making things simpler, but when anything is made simpler you lose flexibility.

    You can do it the way you mentioned, you can do it the way I mentioned, you could do x = array.width; while x > 0 spawn & x-- Or while array.width > 0 spawn & remove item from array. All the loops do the same thing just with different formatting to make it simpler in different situations.

  • The problem isn't about the negative index itself, but the behavior of the loop itself. By using end = -1, what I expect is that the loop shouldn't run at all.

    This is what I was doing:

    > for "spawn" from 0 to array.width-1 {
    	create enemy...
    }
    [/code:3rq61buy]
    So if the array size (width) is 2, I will get loop: from 0 to (2-1) ==> result: new enemy.IID 0 & 1.
    If the array size is 1, I will get loop: from 0 to (1-1) ==> result: new enemy.IID 0.
    If the array size is 0, I will get loop: from 0 to (0-1) ==> result: new enemy.IID 0 & -1???
    
    Using multiple by -1 will make: from 0 to 1 ==> result: new enemy.IID 0 & 1, which is still wrong as I got empty array.
    
    In short, the for-loop is more like do-while.
    

    So you are saying that the problem is that it will execute with a negative value?

    That sounds like what it should do because if the ending index is lower than the starting it should change to for(i = 0; i > array_width; i--)

    If your only issue is the loop executing when empty why don't you just but a pre-condition as array.width > 0 ?

  • Setting the scale to integer/browser.DevicePixelRatio did restore pixel-perfect under crop setting.

    Ashley despite the warning it still seems as the crop setting would be the easiest way to create a 'integer scale outer' so to speak. As now that I have it with pixel-perfect all I need to do is check the screen size and set to desired integer, which right now I'm only seeing that 1 and 2 will be needed

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I wasn't aware of this and am also interested in hearing the answers to your questions, but if you need a simple work-around you can always multiple by -1 or take totalindex-loopindex to count backwards