AllanR's Forum Posts

  • sebastiangohhy

    You have to zero pad numbers if you want them to sort properly - the array sort does a text based sort.

    so, when you put a number into the array use zeropad(number,digits)

    when you need to use then number later, convert it back to a number using int(arrayvalue) or float(arrayvalue)...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Dain

    in your player 2 group, you changed Gamepad 0 to Gamepad 1 in the top Gamepad field, but in the value field you still reference Gamepad 0.

    Gamepad.Axis(0,0)/4 should be Gamepad.Axis(1,0)/4

    in all cases the first number in the .Axis expression should be 1 for Gamepad 1

    don't forget the two occurrences where you set bullet angle of motion in event 29.

  • bbjGames

    I think you will always get the lowest total by multiplying the biggest number by the smallest, then the next biggest number by the next smallest...

    you shouldn't have to try every combination. Just sort them and match them up - first with last, second with second last...

  • tetuan

    I would create a function to pick the next word, and remove the random action in event 3. (You don't really want to keeping picking a word every cycle of the loop). When the loop finishes loading the array, then call the function. The function can pick a random word and delete that line out of the array so the word does not get picked again. And the function can reset anything else that needs resetting.

  • MPPlantOfficial

    you can also use TouchID to keep track of which touch should apply to which object.

  • newt

    Are you sure you are running the layouts in the order you think you are? (I always forget to select the layout I want when testing).

    it works the way I would expect. There are two loops - an inner and outer loop. The inner loop "y" runs 9 times for each of the outer loop "x" cycles.

    when you create the sprite object, you will get either rows or columns depending on which order you put the loopindex variables in the create object.

    The first layout gives me rows the way I would expect, because the first coordinate given is the Y loopindex.

    The second layout makes columns because the inner loop is now in second coordinate...

  • jhjconstruct

    I do a lot of database work with C2. I typically use 3 arrays: one to hold the data, a second one to filter the data, and the third to sort the filtered data.

    The filter array only needs one column, which is the row number of the main array for any rows matching the filter criteria. The index array has two columns - the first is for the data being sorted, and the second is the line number to the filter array (which is just a link to the main array). basically you copy the column you want to sort from the main data array into column 0 of the index array, (and the row number it came from in column 1). Then use C2's array sort. This works great for databases with up to thousands of records. After that, you would want to send queries to your database, and let its engine do the work...

    I made a quick sample, just using a main array and an index array. first it loads some data, then sorts the main array (in descending order). Then it builds the index with a primary and secondary sort field.

    You will see that I often use constant variables for the field names - this makes reading the code much easier a few weeks / months later when you are trying to figure out what is going on...

    you can get my sample here: http://www.rieperts.com/games/forum/SortArray.capx

    for your original question, if you just have columns: score, name, address in your array

    and only want to sort by score, then you do not need to make an index, just sort the array. The name and address will stay with the corresponding score.

  • tunepunk

    Rather than add them to an array, can you just set an instance variable? Kind of like what ROJOhound suggested, but without the intermediate step of collecting the UIDs, then setting the instance variable to pick them later... just set the Picked variable in the loop that would save the UID or add it to the array.

    How often does this need to happen? Is it actually affecting performance? processors can loop through a lot of data before it becomes a problem!

  • mchulet

    I just grabbed a random clock face from a google search and then made the hands smaller so they fit on it.

    Yes, you can calculate any angle you need from a given time, or check the time from an angle. So, if the time is 8:50, then the angle for the hour hand will be 8 x 30 + 270, and the angle for the minute hand will be 50 x 6 + 270.

    the general formula from a given time is:

    number of minutes x (360 / 60) + 270

    number of hours x (360 / 12) + 270

    or if the hands have been set, and you want to know what time they were set to:

    hour: round(((clockarmhour.Angle+90) / 30)%12)

    minute: round(((clockarmminute.Angle+90) / 6)%60)

    seconds: round(((Sprite.Angle+90) / 6)%60)

    (We have to add 90 degrees to get the angle back to what C2 understands - since we added 270 earlier. If we subtract the 270 out, then we get negative numbers that are slightly harder to deal with. At the end we have %12 or MODULO 12 to keep the hours between 0 and 12. The minutes and seconds have %60 to keep those numbers between 0 and 60)

  • Triforce

    you can set "Unbounded Scrolling" to yes in the layout properties, then the world can extend forever. You just have to generate the world as people go.

    You may want to read up on Perlin Noise. There is a noise plugin for C2. That allows you to pick a seed number and then generate consistent results for your map at any given coordinate. (This is how MineCraft builds their worlds).

  • wirelesstkd

    Ashley wrote a great blog post about lerp here: https://www.scirra.com/blog/ashley/17/using-lerp-with-delta-time

    The reason why the example you followed slowed down is probably because the first value in the lerp expression was being updated every tick. So, the distance the sprite moves gets smaller and smaller as it approaches the target location. This provides a nice ease in effect (if that is what you want - which you don't).

    eg: Set Sprite.x to Lerp( Sprite.x, TargetX, dt )

    Sprite.x changes every time the expression is evaluated (and is used inside the lerp expression), so the amount the sprite moves each step of the way is reduced as it gets closer to the target - which slows it down. since you want a constant speed, you need to change the third value in the expression (the percent moved from value1 to value2) without changing value1.

    eg: Set Sprite.x to Lerp( StartX, TargetX, percentMoved)

    when percentMoved = 0 the sprite will be at StartX

    when percentMoved = 0.5 the sprite will be half way between startX and targetX

    when percentMoved = 1 the sprite will be at targetX

    so, as percentMoved changes from 0 to 1 (or 0% to 100%) the sprite will move at a steady speed (as long as percentMoved changes at a constant speed).

    You just have to be careful not to change startX or targetX while the sprite is moving.

    If you add dt to percentMoved every tick, then it would take 1 second to move from startX to targetX.

    but since you want the move to take 0.5 seconds, you want to add dt*2.

    I made a quick sample here: http://www.rieperts.com/games/forum/lerp.capx

  • mchulet

    you were very close - and had the right idea. The main trick is to get the image points and initial angle correct.

    In C2, Zero degrees points to the right, so it is a good idea to have images facing that way and then set the origin on the left edge. That way, when you set the angle to point to the mouse it will work the way you expect. The only other thing to remember is that a clock assumes that Zero degrees is pointing straight up - so you have to add 270 degrees to an object to get them to the correct place as far as the clock is concerned. Since there are 60 seconds per minute, the second hand moves 360/60 or 6 degrees every second (and so does the minute hand because there are 60 minutes per hour). The hour hand moves 360/12 or 30 degrees every hour.

    you can download my version of your capx here: http://www.rieperts.com/games/forum/clock.capx

  • radhaw

    the problem is the joystick is only looking for "Is in touch". So, when you touch Sprite4 to fire, that will also affect the joystick, because "Is in touch" is true.

    To do a proper multi touch interface, you have to track each start and end of each touch by their index. It gets pretty tricky but is possible.

    for your example, you can (mostly) get it to do what you want by adding another condition to both event 3 and 4 that says:

    Touch > Not is touching Sprite4

    ( to do a Not, add a condition that says Touch > Is touching Sprite4 and then right-click it and choose invert )

    The only problem I had with this simplified multi touch, is that the joystick stops responding if you hold your finger on the fire button (sprite4).

  • Gamesmeir and OddConfection

    OddConfection is correct, but an easier way is to use Replace

    Global text Example = "Hello/nWorld"

    then at start of layout...

    System > Set Example to Replace(Example,"/n",newline)

    (Replace will replace all occurrences, so there can be multiple /n within the string. Obviously this wont work with Constants because you can't change the value of a constant, but then whenever you use Example you will get the desired result.)

  • X3M

    Wow, that is rather alarming that it is that easy to change variables like that. I had never used the console like that before, so I played that first game you linked to, gave myself all the lives I wanted, all the coins I needed to buy all the upgrades, whatever score I wanted... if my health got too low, I could just pause the game, set my health back to full and then continue on.

    encrypting every important variable in a game seems like a lot of extra work and overhead, but what else can you do? I guess keep track of key presses, mouse clicks, and time in game so you can estimate if the score is possible (and encrypt those values too). Maybe keep multiple copies of some variables (in different forms) and test for hacking, or leave some honey-pot variables unencrypted to see if someone is trying to cheat.

    Like newt said - anything can be hacked, but it should not be possible for a complete novice (like me) to completely defeat a game in a few seconds! I guess if you want to keep Global leader boards, you could keep code for testing whether the score is valid or not on the server. But they would still be able to see how the data is assembled to be sent to the server and eventually reverse engineer it.