zatyka's Forum Posts

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • Please don't take this personally, but it's very difficult to make sense of your description, and ever more so, the capx. It's a lot easier to provide assistance if the capx is concise, and your desired result is fully explained.

    I'm not sure exactly what you're goal is, but I think I may have deduced it. I'm guessing you want the player to hold the down arrow button to charge up the yellow bar, and if the the player presses the red button while the yellow bar is charged, Sprite 2 appear. You also want the bar to maintain its width for the duration of the animation, and then return to it's original width.

    Andreylin mentioned that you can trigger something to happen at the end of Sprite 2's animation, but that won't work in this case, because you don't really end Sprite 2's animation, you just set it to invisible after the animation has completed. Therefore, the quickest fix I can think of was to only have the yellow bar change width when the Sprite 2 is invisible.

    I hope this is what you were looking for.

  • I can see this topic becoming better suited for the �How Do I....?� forum, but here goes nothing. I'd rather not post the capx for a couple reason:

    • The engine is the basis for the project I'm currently working on and I'd rather not make it public at this time.
    • I'm not sure how useful it would be to someone unfamiliar with the different components making up the engine. There are quite a lot of things going on at once in the demo, and while the code is organized, it would take quite a while to decipher.

    However, I'd be happy to discuss specific components that make up the engine (or point-and-click adventure games in general), and perhaps whip up a tutorial or demo capx if appropriate. For example, here are a couple components of the engine:

    • Movement - The demo uses platform behavior, but only because the game is in the style of a 2D side scroller. For more traditional point-and-click adventure games, you'd use path finding in conjunction with other processes (like z-ordering of objects).
    • Zone Comparison - The level is broken out into different zones, with some zones overlapping others. Every time you click on an object, or use 2 objects together, a process compares the hero�s current zone(s), and and the target object�s zone(s). If they share a zone, an action can be executed.
    • Action Interface - The demo uses a pop-out icon interface to shows a set of actions contextual to the item selected, but a static action menu (e.g. Secret of monkey island/King�s Quest 5) is similar, and much easier to implement. When a user executes an action, a timeline is generated.
    • Timelines - Almost every time you execute an action in the demo, a timeline is created and populated with one or more pre-set function. Each function is executed in order, one-by-one, for one or more objects, usually the hero. For example, when you pick up an object, a timeline is created and populated with functions that move the hero to the object, adds the object to your inventory, destroys the object, and displays dialog.
    • Inventory - The inventory gives the player an interface for displaying, and performing actions on items acquired during gameplay. Also, using items in your inventory on other objects within the level.
    • GameClock - Definitely not a standard component for point-and-click adventure games, but useful for certain puzzles. For example, in the demo I posted, you can grow a plant if certain conditions are met, and a certain amount of time passes.
    • Player Choices - Though not part of the demo, giving the user a set of options to choose from is a staple of the point-and-click adventure game genre. It�s most commonly used when giving the player choice of dialog between the hero and NCPs.

    There are certainly other components of point-and-click adventure games, but the above components are some of the most important.

  • It's a lot easier to explain with an example:

    Demo

    Capx (with annotations)

    I hope it helps.

  • I've been working up a 2-d (think side scroller) point and click game engine. Here's a test I uploaded a while back:

    Point and Click Demo

    Click anywhere to move.

    Click and hold the left mouse button over an object to select it, and release the mouse button when you're over an icon to select an action.

    Construct 2 is quite capable of point and click games, especially with the new path finding behavior.

  • As long as you're saving all the necessary data to something with a global scope (like a global variable, or an array), you should have no problem using that data across different layouts. I'd double check to make sure there aren't other factors affecting the information being displayed.

    If you're still having problems, post your capx.

  • What exactly is the desired result? Do you want the lasers to shoot straight, endlessly, until they run into an obstacle, or do you want a 1 to 1 relationship , where each laser aims for a specific switch?