mekonbekon's Recent Forum Activity

  • lennaert

    RobertoFreemano

    That's a really nice example especially because you don't need to resort to arrays. One adjustment I'd make however is to:

    int(random(FirstNumber,LastNumber))

    I'd change this to:

    floor(random(FirstNumber,LastNumber+1))

    Otherwise the first and last number will be picked half as often as every other number.

  • red1m3n

    Or have a second variable orderNo and a global for each order. If you have a lot of orders then you might just want to switch to using an array instead of using globals:

    Each row would be an order and the columns would be Main,Side_1,Side_2,Side_3. You could still use the addition trick I described above to compare AI order and player selection.

  • Hi red1m3n,

    As long as the three sides are all different and it doesn't matter which order you select the sides in you can use a neat little addition trick:

    Give each side an instance variable "value".

    For each side assign "value" an increasing power of two e.g.

    sideA = 1

    sideB = 2

    sideC = 4

    sideD = 8

    sideE = 16

    etc

    Create a global called "AITotal".

    Assign AITotal the sum of "value" for the three selected AI sides. This value will always be unique for each different combination of sides.

    Create a global called "PlayerTotal".

    Assign PlayerTotal the sum of "value" for the three player selected sides.

    If AITotal is equal to PlayerTotal then the player has selected the same sides.

    In fact I think this might work even if you have duplicates of the sides in the choice of three.

  • capx

    https://www.dropbox.com/home?preview=gun+angel.capx

    Hi Road Move, this just links to the dropbox home page. To share a link you need to generate it by clicking on the "share" button.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • beanboy354 The capx is the project file. You can stick it on Dropbox, Google Drive or similar.

  • mekonbekon Thank u for the reply. Now, it solved already. thank u so much..~

    You're welcome - and thanks for the nice comment on Thanks Chicken, I'll be doing a small update to it fairly soon

  • beanboy354 Do you have a capx you can share?

  • skrotar

    When you buy multiple of an item do you want the cost per item to remain the same for that multiple purchase or to compound ?

    e.g. if it was my first purchase and I want to buy 10 then if the price remained the same per item the total cost would be 60 , but if it compounded it would be 6+9+13+19+... etc

    Calculating the former is simple, it's just bulkCost = itemNo*itemCost

    then you step up the item cost for the next purchase:

    itemCost = floor(itemCost*(1+mulitplier))

    To find the max purchase, if C is the number of coins then itemNo = floor(C/itemCost) and then you reapply that value to the bulkCost formula.

    If, on the other hand, you want the cost to be compounded on bulk buys you could use the traditional compound interest formula. The formula is:

    A = floor(P*(1+r)^t)

    A = the bulk Cost, P is the starting cost, r is the rate of interest and t is the number of items purchased.

    so in the above example the formula would give:

    A = floor(6*(1+0.5)^10) = 345

    However this will give you a different result than if you looped to calculate the bulk cost using:

    Trigger once: Set bulkCost to itemCost

    Repeat itemNo-1 times:

    itemCost = floor(itemCost*(1+multiplier))

    add ItemCost to bulkCost

    ...because you're flooring the itemCost on each iteration, rather than just flooring the final result. I'm guessing that this looping calculation is the one you're after.

    Now, for the final part of your question: how to calculate the max purchase for compounds:

    Let C be the total number of coins.

    Set bulkCost = itemCost

    Set itemNo = 1

    Trigger once:

    while bulkCost <= C:

    add 1 to itemNo

    itemCost = floor(itemCost*(1+multiplier))

    add ItemCost to bulkCost

    This while loop will continue until you've exceeded the number of coins, after which you will need to step down the itemNo by one to get the max purchase:

    If bulkCost > C, Trigger once

    deduct itemCost from bulkCost

    deduct 1 from itemNo

    I think that will work,haven't checked it yet though - I'll try and put together a capx later. I'm also fairly sure there's a more elegant solution than this - hopefully some kind soul will enlighten us both.

  • Hi,

    If the enemy only spawns a coin when it dies from an attack, use:

    On enemy destroyed > Enemy spawn coin.

  • Hi bizzy401,

    The link you posted for the capx is contracted - you need to post the full link for us to be able to download it.

    Some things to check before you update the link:

    1) Is your origin point for spr_Room in the top left corner?

    2) This statement...

    spr_Room.X+(0),spr_Room.X+spr_Room.Width-(1920)

    ...means that if a room is 1920px width then your bounding box for the camera is going to run from the left edge to... the left edge. Similar story for the Y axis. I'm pretty sure that's not what you want. I'm guessing you'd have more luck with something like:

    spr_Room.X+960, spr_Room.X+spr_Room.Width-960

    That would centre the camera in a room that was 1920 pixels wide and for wider rooms stop the camera moving 960 pixels from the left and right edges. For the Y axis use 540.

  • Youtopize - I meant to comment on that Double click on the sprite to open the sprite editor, select each animation and in the properties window set the Speed to 0. After that you don't need the stop animation event.

  • If you want to modify this code, increase both instances of the value 160 to reduce the area that the camera will scroll within a zone, and reduce the 0.1 in "0.1*60*dt" to make the camera move slower.

mekonbekon's avatar

mekonbekon

Early Adopter

Member since 9 May, 2014

Twitter
mekonbekon has 13 followers

Trophy Case

  • 10-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • x2
    Popular Game One of your games has over 1,000 players
  • Famous Game One of your games has over 10,000 players
  • Coach One of your tutorials has over 1,000 readers
  • RTFM Read the fabulous manual
  • Great Comment One of your comments gets 3 upvotes
  • Email Verified

Progress

18/44
How to earn trophies