Pecek's Forum Posts

  • -Silver-

    random(3000) + 3500

    random(3000) + 7000

    You only have to randomize the differences.:)

    Edit: a quick example, look at the first one. You want to create a random between 3500 and 6500. If you do it like this: random(3000) + 3500, and the random returns 20, you will get 3520, if it returns 1500, you will get 5000, and so on.

  • If you want to save other things too, dont use the text manipulator object, it doesnt designed to this kind of job.

    You can use the hashtable, array, binary, ini or the file object(or python of course.)

    I don't know much about the binary object, so I won't suggest to use that(but this isnt mean its not perferct for your problem.) I usually using the array and\or the hashtable, lets just say you want to save the player's name and the current level(if the game isnt linear it's a bit more complicated, but you can figure it out if you get the main idea.)

    So, the hashtable. It's working with "keys" and "values", this means you can save variables under named strings, like "player1name"(key) - "joxer"(value). In the profile menu you can get the profile names like this(if you have 10 profiles for example - of course you don't know how many profiles will be on the player's computer, but you can limit it):

    + System: For "profile_names" from 1 to 10

    -> Text: Set text to Text.Text + NewLine + HashTable ("player" + str(LoopIndex) + "name")

    Now you have every user name. You can save the data the same way, just use an another key. "player1level" - 5, from this you will know that player1 is completed the first 5 level, and so on.

    If you don't understand how the event works:

    System: For "profile_names" from 1 to 10   - this will start a loop 10 times

    Text: Set text to Text.Text   - you have to check the existing data, or you will only see the last one

    NewLine    - this one just adds a new line to the end

    HashTable ("player" + str(LoopIndex) + "name")   - the syntax of getting a value from the hash is this: hash's_name(key_name), we know that the our usernames are in this format: "player" - slot number - "name", so we'll looping through every possible solution(from 1 to 10), and check it's value.

    str(LoopIndex) - the LoopIndex function return the value of how many times the current loop was executed, at the first time it'll return 1, second time 2, and so on, but it's returning a numeric expression, so we have to convert it to string with the str() function.

    Sorry about my terrible english, I hope you can understand me more or less.:)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The random function only need one argument(in this case the 3000.) If you want to create something betwen lets just say -50 and 50, you can do it like this:

    random(100)-50

  • Use a hashtable for example.

    HashTable.InsertKey("player name", player score - this should be a global/private variable)

    After that, you can loop through all of it's elements(if i'm correct it's sorting automatically)

    HashTable.ForEachElement:

    Text.SetText(Text.Text + NewLine + HashTable.CurrentKey + " " + HashTable.CurrentValue)

    Note: you probably wont get an answer if you dont want to think, nobody wants to create your stuff, but lots of us would like to help. There is a difference.

  • it's a clearer solution in my point of view if you using a global variable("enemy_hit_bar" for example), and a private variable("id"), assign this to every enemy.

    When you hit the enemy, save it's pv(id) to the globalvar(enemy_hit_bar), after this, you can easily define wich is your target like this:

    for each enemy:

    if enemy.value('id') == globalvar('enemy_hit_bar'):

    <the code where you set the hp bar>

    this will pick the correct instance, and you can debug it a lot easier beacuse you don't have to check every instance by hand if something went wrong.

    Edit: and don't put the hp bar in the container when you only want to display one.

  • Pumpkin_head

    ..I think I was wrong, if I'm correct the array object using 1 based index instead of 0, so the first iteration of the for loops isnt doing anything at all.

    + System: For "y" from 1 to 20

    + System: For "x" from 1 to 20

    Use this instead of the first solution(that works fine too, but if you can optimise, you should optimise.:P)

  • Pumpkin_head

    Sure, if you know where to start\stop the iteration(sometimes you just have to go through the whole array.) The first 2 event in the set tile type group should look like this:

    + System: For "y" from 0 to 20

    + System: For "x" from 0 to 20

    + Array: Value at (LoopIndex("x"), LoopIndex("y")) Equal to 0

    This will loop through the first 20*20 element of the array.

    Edit:

    and replace this:

    global('OffsetX')+(Array.CurrentY-Array.CurrentX)*(global('Tile_X')/2)*-1

    with this:

    global('OffsetX')+(LoopIndex("y")-LoopIndex("x"))*(global('Tile_X')/2)*-1

  • Pumpkin_head

    You're welcome, if you have any problems feel free to ask.

    Btw be carefull when you looping through a huge array, it's never a good idea to iterate 10k times on every tick, and it's pointless almost every time.

  • you can gain a lot more speed if you change this group:

    Set_tile_type_according_to_Array_Value

    Do not loop through the array every tick, only when you change something, i had 20-23fps, after i disabled the group it was stand still over 300.

    Check your other pointless loops too, replace the allways events with "on every 10-20 ticks"(if you don't have to check it allways of course), after 2-3 minutes of editing i got over 800 fps, with the same functionality.

  • I dont understand the sound problem, post the cap please - its working correctly here(I tried the xaudio and the audiere plugin too.)

    These are the resources

    <img src="http://dl.dropbox.com/u/2721498/2stroke/Construct/forum%20help/resources.png" border="0" />

    By default the panel is on the right side, if it's hidden, home->project.

  • In the srpite object,there is a funticon 'load external images from file'.

  • You can't do that with the Text object.

  • I know it's in the early stage(probably abandoned tho), but it's awesome, so I would like to use it in my animation editor.

    Without any documentation it wasnt easy even to find out how can I display something, but I dont have a single idea how to use the window widget's close button.

    I tried this, but nothing happened:

    + System: Start of layout

    -> InputSystem: Set mouse position to X:Window.X+Window.Width/2 Y:Window.Y+Window.Height/2

    -> CGUI: Load layout "unnamed.layout" with widget "" as parent

    -> CGUI: Widget "windowww" set event to On mouse move over (sender, left, top)

    + CGUI: On Widget "windowww" mouse move over

    -> CGUI: Destroy widget "windowww"

    Of course this should close it when the the mouse is on it, but it didnt worked also. Ideas, anyone?

    Edit: also I have no idea how to retrive any of the properties, this is a lot more important because the scrollbars are useless if I can't.

  • dl.dropbox.com/u/2721498/2stroke/Construct/cap/inventory_array%26hash.cap

    Maybe this will help. You can change the size of the "inventory" at the first event(dont forget to change it at the 6th too if you want to use the hashtable solution.)

  • Yup, I did the same while I was waiting for a respond. Thanks anyway.