zatyka's Recent Forum Activity

  • I whipped up a demo using nodes to define multiple paths (lanes) for cars to follow. The cars will change lanes every few seconds.

    Demo

    Annotated Capx

    I hope this helps.

  • For common game elements, there is often a myriad of past topics covering the subject. You'd probably have good luck searching the forums, and checking the Frequently Asked Questions topic.

    Here is an example using an array:

    Demo

    Capx

    Regarding efficiency, I suppose it really depends on how you want the inventory to function.

  • You may also be interested in the Sine Behavior, which would produce a similar effect.

    Capx with the effects side by side.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ah, I misinterpreted you original post. You're looking to determine all factors for a number. Well I'm sure there is a more elegant way to do it, but here's one method:

    Demo

    Capx

    I use a method called trial factoring. Basically, you take the starting number, take its square route and round it up to the nearest integer(i.e. whole number). Let's call that number "i". Now, try dividing the original number by every integer between 0 and i. For every division resulting in an integer, both "i" and the result are factors. Here's an example:

    Starting number = 22

    The square route of 22 rounded up = 5

    22/1 = 22, so 1 and 22 are factors

    22/2 = 11, so 2 and 11 are factors

    22/3 = not an integer, so no factors

    22/4 = not an integer, so no factors

    22/5 = not an integer, so no factors

    I hope this helps.

    EDIT - Updated capx to use a much less convoluted method for testing for integers, incorporated an array to make sorting easier, and annotated everything. AnD4D

  • There is a way to do this, and now that I'm back at my main PC, I can show you. Here's the demo:

    Demo

    Capx

    The Capx is very simple. It ajax requests a php file that I've set up to return the current US Eastern date/time. If you have your own server set up, you can create a similar set up for your own game. Here's the code used in the php file :

    <?php

    header('Access-Control-Allow-Origin: *');

    date_default_timezone_set("America/New_York");

    $datetime=getdate();

    echo("$datetime[hours]:$datetime[minutes]:$datetime[seconds] $datetime[mon]/$datetime[mday]/$datetime[year] ");

    ?>

    I hope this helps.

  • What exactly is your ultimate goal? Is it really just to divide 2 numbers resulting in a whole number. If it is, you've already done that. However, I'm guessing your ultimate goal is something a bit more complex. Could you elaborate a bit?

    When trying to convert numbers with decimals into integers, the following expressions are useful:

    round(x): Round x to the nearest whole number e.g. round(5.6) = 6

    ceil(x): Round up x e.g. ceil(5.1) = 6

    floor(x): Round down x e.g. floor(5.9) = 5

    Taken straight from the system expressions page of the manual.

  • You can store the player's X coordinate into a variable upon jumping, find the difference between that value and the player's X coordinate upon landing, and plug that into a text box.

    Demo

    Capx

    This is some pretty basic stuff. It's probably worthwhile to go through the beginners guide, and check out some of the tutorials to get a grasp of the basics.

  • Based on the original post, I was under the impression that mhgames's goal was to ensure that a player waits for a certain amount of real-world time to elapses before an in-game action occurs (e.g. growing crops in farmville). I still believe my method would work in that capacity, thought there could be a much simpler way to do it that I'm not aware of.

  • Magistross

    You could very well be right about preventing cheating using other methods, but it really depends on the game.

    Regarding latency, I didn't mean to suggest using AJAX server requests to constantly determine the in-game date/time. I was more thinking along the lines of a single AJAX request to determine the date/time upon loading finished or on the start of the first layout, and syncing the in-game clock to the request's result. At that point, in-game mechanics can maintain the correct date/time.

  • I'm pretty sure mhgames is looking for a way to pull real-world time into the game using a source other than the player's device.

    Is it possible? Yes, but there's no simple way to do it from within the editor (unless someone's created a plug-in to do it). You'll need an external source containing the current date/time, and a method of pulling that data into the game at runtime.

    There could very well be an easier method, but one option would be to set up a webpage using PHP to produce the current date/time, and using an AJAX request to pull that data into the game.

  • Rabidsheep's solution is one option. I'll give you another. I'm not at my main PC at the moment, so my apologies if the terminology isn't correct, but did you try something like:

    Every tick: Scroll to Y (Scrolly+60*dt)

    If Hero is not on screen: Destroy Hero

    You can change the "60" to scroll faster or slower.

  • There very well could be a better solution, but I used a mask for each ball that has a larger collision polygon. Using this polygon, I could somewhat accurately detect groups of each ball color. Take a look:

    Bucket Test

    A few things to note:

    • I used the first demo you posted because I found it easier to work with.
    • I changed the drop rate to every .5 seconds because it was painfully slow to test when 1 ball drops every 5 seconds. Changing it back to 5 seconds should not be any problem.
    • I added a few notes to explain what I did.
    • I left the masks visible, but just so you could see what's going on. I'd normally set them to be invisible.
    • A lot of the code in the files you posted is redundant. I noticed in the 2nd capx you posted, you consolidated the different colored balls into a single object, which is good, but you're still duplicating the same couple events for each color. It won't stop your code from working, but it's just good practice to consolidate your code. You could probably run a loop for all the balls, and change the specific color you're looking for within each loop.

    I hope this helps.

zatyka's avatar

zatyka

Member since 11 Aug, 2012

Twitter
zatyka has 1 followers

Trophy Case

  • 12-Year Club
  • Jupiter Mission Supports Gordon's mission to Jupiter
  • x11
    Coach One of your tutorials has over 1,000 readers
  • RTFM Read the fabulous manual

Progress

15/44
How to earn trophies