tulamide's Recent Forum Activity

  • :D Thanks a bunch zyblade and Tulamide!

    Also Tulamide, so your example cap for the array is basically writing data to the array that stores the animation frame its on? And how would I go about creating an inventory using an arrya, would I write a variable to an X,Y position on the array? Or would using 'S' be more useful for this?

    It depends on how your inventory is organized and what information has to be saved. Use an array whenever you can map a situation in your game directly to a bunch of cells. For example, if your inventory is a bar with a fixed number of slots, it is very easy to map slot a to cell 1, slot b to cell 2, etc.

    If your inventory is more like in an rpg, a bag that can store a non-fixed number of objects, then a hash table would be more suitable. You could create a key with the name of the object and a value representing the id or position in the bag's list.

    You can always store more than one information at once. Just use strings instead of numbers. In an array, you could fill a cell with the string "Green Pill, 25, 12.52, C" and later extract the informations using the expression 'get token'.

    But if it is a really huge number of informations that needs to be stored per inventory slot, you might indeed consider using 's'. With its ways to create data structures and reference them in other superstructures, it is way ahead of any other method in Construct, as soon as something is object oriented.

  • I also made a more complete tutorial about arrays and hash tables a year ago. It includes demo caps besides the written explanations.

    http://www.scirra.com/forum/tutorial-variables-arrays-hash-tables-an-overview_topic41773.html

  • I just removed the physics behaviour from the second arrow, cause it was multiplying the effect and was too speedy. :)

    My bad. It wasn't intended, I just forgot to remove it after duplicating the original sprite :)

    I'm glad that it was of help.

    With physics and angles: Don't forget that there's friction and the like, so objects need to be rotated physically correct on contact by the engine - that's why rotating an object manually would break it.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • A few things to mention:

    You can't directly change the angle of the object (just as you can't directly change the position of the object) without breaking the physics behavior.

    The sprite was drawn with facing up as initial state. But initially all sprites are at 0�, which is facing right.

    To get the rotation just add a second sprite, set it to always be at the first sprite's position and cache the last position. Then just set the angle of the second sprite to the angle between the last and actual position.

    Here is an example: phys_Angle.cap

  • Double post because of "500 - Internal server error"

  • I'm having a problem with loops:

    ->Make Super Array {""}: "ASDF"

    ->Make String Array {"ASDF"}: "stringasdf" with default 0

    +"asdfloop" For Each String at {"ASDF"}

    This causes a crash.

    's' is very stable. That means, for me it is only crashing, if I did something wrong or illogical.

    Be careful of what you define and how:

    • You need a super to store some string arrays.
    • You need one string array to store some strings.
    • You need to tell the loop the complete path to the string array of interest to loop through.

    In the example above you added a string array with the name "stringasdf" to the super "ASDF", but you expect 's' to loop through "ASDF", which is no string array. The correct path would be

    "asdfloop" For Each String at {"ASDF", "stringasdf"}

    Of course, you should add some strings to "stringasdf" or else there is nothing to loop through ;)

    Here is an example cap: using_s_string_loop.cap

  • I would rather suspect the file being corrupted, than thinking of a bug in Construct.

    I work with Construct for two years now. Usually I save a limited time to one file. With every major feature added, I create a new save file.

    I never ran into issues with saving.

  • No offense, but with those 14 words you won't get much help, if any.

    I know how difficult it can be to write in english, when you're from a country with another language (I come from germany, for example)

    Most of the people with english as their native language don't mind a few mistakes. But this is just not understandable. You should use a translator better than google, or find a friend who can help with describing the problem.

    Also, provide a cap showing the issue. It helps a lot more than a description.

  • My apologies, I meant angle of the sprite and not the angle of motion.

    Ah, yes, that makes sense. And lucid's graphic should make it more clear.

    But here is a practical example:

    Again, the sprite is moving with 50 pixel per second at an angle of 10?

    x-component 49.24

    y-component 8.68

    Now the sprite rotates to 330?. The player hits the thrust button (max speed again 50 pps)[or a planet gets into the influence of another mass, something like that]. Now you need to aim for a final

    x-component cos(330) * 50 -> ca 43,3

    y-component sin(330) * 50 -> -25

    So you need to interpolate (qarp should do) between

    x 49.24 and 43,3

    y 8.68 and -25

    for whatever time feels right for your game.

  • If you are afraid that you could forget to create it, just make a function and call it instead of creating object and data structure in the actual event.

    +on function "create"

    -> create object

    -> add array

    + some trigger

    -> "create"

    <img src="smileys/smiley2.gif" border="0" align="middle" />

  • Maybe I am misunderstanding this. but "horizontal" and "vertical" relative to the angle of motion doesn't make much sense.

    When your object moves with 50 pixel per second at an angle of 10�, then the speed's x-component is cos(10) * 50 (ca 49.24), and the y-component is sin(10) * 50 (ca 8.68)

    But a relative "vertical" component to an object moving at any angle would just be the speed (cos(0)) and the "horizontal" one would always be 0 (sin(90))

  • So I guess instead of asking "How" to do it with S (I'll figure that out) let me just ask, is it possible to take a family of objects, and every time I create an instance of one of the objects in that family either in the layout editor or at runtime, the appropriate data storage structure is created with S? (Note that just replacing families with S for everything is not ideal since I already have a ton of events that use family functionality that I'd rather not replace. However, putting all the objects in said family also in an S structure and doing it would be just fine).

    Well, without going too deep: You can.

    If you created your template of the data structure and a super that stores arrays of them, it is very easy:

    + some trigger

    -> create object 'someobject'

    -> super, add array from template 'somestructure'

    -> super, lastarray, id = someobject.oid

    (or just store the object itself, which is more comfortable, as you can then pick it later from within s, without any trigger or condition needed)

    + some trigger

    -> destroy object 'someobject'

    -> super, loop through arrays, until id = someobject.oid

    -> super, delete array

    You may also want to have a look at Python. It is also very easy to realize it. You'd create your data structure as a class or a dictionary on startup and just store copies of it in a list or other container, together with the object reference, whenever it is created.

tulamide's avatar

tulamide

Member since 11 Sep, 2009

Twitter
tulamide has 3 followers

Trophy Case

  • 15-Year Club
  • Coach One of your tutorials has over 1,000 readers
  • Email Verified

Progress

17/44
How to earn trophies