Guizmus's Recent Forum Activity

  • Well, you could call the same function in your events the game calls when a tilt is detected when clicking on a button, but in any case, you won't have the tilt orientation. To test it truly, you'll need a friend (or another device)

  • Let's go for another example but first some things :

    • use the "Debug layout" feature. This way, you can check in the console the content of an array without having to display it. Same goes the AJAX.LastData
    • in C2, an error we all do at first : if a text object isn't big enough to write its text, it will cut after the last word it can display. In your case, 1 word only (no spaces) too big => no display. It works perfectly.
    • your json has some values C2 doesn't accept, like 8.000.000. It can't load your array from JSON and doesn't raise any errors.

    So I did an example, where, check the events :

    • events 1-3 : I load an array and do some debug on it to display every data it holds. (this part isn't active)
    • event 4-5 : I populate manually an array with the datas you wanted, and download it to check the format of the JSON

    So to sum up :

    • don't display big ass texts in little objects
    • don't use unsuported types in array (stick with int, float and string)
  • This isn't simple at all, sorry, and if you want to use it, you will have to adapt it to your case.

    I'll try my best :

    The weight is called "bitwise" in the capx. There is a different bitwise for every surrounding configuration. It is manipulated in decimal form here, but is thought in binary form. For explaining it, I'll write it down like this : 101[2] = 5[10] (where the [X] is the base used for the number. So here 101[2] means 101 in binary, and 5[10] means 5 in decimal)

    • If the tile above is empty (air), then add 1[2] to bitwise.
    • If the tile on the right is empty, then add 10[2] to bitwise
    • If the tile on the bottom is empty, then add 100[2] to bitwise
    • If the tile on the left is empty, then add 1000[2] to bitwise

    That means that, if you want to set the tile to bitwise :

    • the tile number 0 in your tilemap (the first one top left) should correspond to 0[10] = 0[2] = no empty space around. This should be the tile where there isn't any grass on it
    • the tile number 1 in your tilemap should correspond to 1[10] = 1[2] = only air above the sprite, so a sprite with grass on top
    • the tile number 2[10] = 10[2] = only air on the right => grass on right
    • the tile number 3[10] = 11[2] = air on top and right => grass on top and right, angle at top right edge
    • the tile number 4[10] = 100[2] = air only on the bottom

    And so on... This means that, to use this method, you will need to have a friendly tilemap, or you will have to reorganize where each tile is on the tilemap image.

    • You can pre-populate a tilemap using the "tilemap bar" in construct 2's editor. Check in your tab "View" to see if the tilemap bar is checked.
    • If you only have solids in this tilemap then yes, you can add the behavior. Remember that every tile in the tilemap will be solid. If you only want some things to be solid, I recommend using multiple maps on top of each other, and have one handle the solid behavior and collisions.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Arrays in C2 are all 3-dimensional. No more, no less. So it should be ok.

  • Yes, you have only 0-based arrays. If you want to access the first line, representing the "KNIGHT" characteristics for example, you could create variables :

    • "KNIGHT" = 0
    • "BASE_LIFE" = 0
    • "BASE_ATTACK" = 1

    And access the array with Array.At(KNIGHT,BASE_LIFE), or Array.At(KNIGHT,BASE_ATTACK) instead of Array.At(0,0).

    If I'm guessing right and you are aiming to store pre-computed characteristics of object types with the array, I would suggest you try the unofficial CSV plugin, as it seems quite adequate here.

    EDIT : and by variables I mean constants. I would put them in a separated event sheet named "define" and include this sheet everywhere. You seem to be quite familiar with algorithm and programming language so this should go without explanation.

  • Yeah sorry, I hit the Tab + space combo in quick reply box ^^ I edited it though

  • The problem is your json file. It has its own structure, but if you want to directly load the JSON inside the array, you have to have the same structure as the array in C2 has. To know how to represent an array in JSON in C2, you start by downloading the array (like I put in my example before).

    By the way, you won't be able to have associative arrays in C2. Declare some constants (some defines) to access more easily the keys if you want to, but the JSON provided won't be usable as it is.

  • What did I do... I tried to structure the code a little more, using sub-events (events inside of each others).

    The E key pressed will start an event where, depending on the state of the game (is the player inside the car ?), it will do different things.

    • if the player is out of a car, the game tries to find a car near the player. The first one found will put the player inside it by calling a function, and passing it the car.UID. This way, only this car will be activated, as the function starts by selecting only this car (Car.SelectByUID, event 9)
    • if the player is in the car, we just get out of it, disabling every car's movement and enabling the player to move.

    The only difference with the screen capture from before is the "Stop loop" I added on event 8, as it will stop as soon as a car is found near the player.

    The functions are here to make it clearer.

    Well, I didn't handle the scroll as your problem was with the car selection/activation... If the scroll is on the player, then you should "Pin" the player to the car he is in. Right now, you put the player in the car, then drive the car, but the player stays in place. Use the pin behavior, activate it in the getInCar function after putting the player inside the car, and deactivate it in the getOutofCar function

  • What do you mean by "it gets to the original sprite" ?

    All cars were moving yes, that is the problem. The changes I suggested should still comport other bugs, like the fact that you can enter 2 cars at a time if you are near both. If you want to do it properly, use functions and UID, like this. (this is a corrected example. I deactivated car2 group for testing purposes, used UID and functions, and it works nicely)

  • This is caused by your event number 7 (and/or 13, same script for both cars) where you active the controls of the car, but don't select a car first. You need to pick the car in the conditions first if you want to act on this car, or else you will act on every car.

    For this, as you choose the car by calculating a distance, you need a foreach condition.

    Here is what those events would look like.

  • Just a question then : what is inside your "testing.json" file ? Like I said, in my example, the json file was empty.

    My first guess here (you should post your capx, it's easier to find, not to guess) is that your json is empty, thus your array is empty, thus the text stays empty.

  • Ok, so here is an example of exactly what you want, using the bitwise method. I couldn't explain it very clearly (you calculate a weight for each tile, depending on the surroundings, and deduce what tile to use), but the capx is explained and clear.

    I take no credit for this as I found it in the comments of this tutorial.

Guizmus's avatar

Guizmus

Member since 26 Mar, 2013

None one is following Guizmus yet!

Trophy Case

  • 11-Year Club
  • x4
    Coach One of your tutorials has over 1,000 readers
  • Educator One of your tutorials has over 10,000 readers
  • RTFM Read the fabulous manual
  • Email Verified

Progress

15/44
How to earn trophies