Curious Mike's Recent Forum Activity

  • I'm not sure I understood the question! But would it help to select the objects by Object.uid? You could store the uid of a clicked object and then use the variable to select the object again.

  • This will help you to understand the basics of arrays:

    scirra.com/tutorials/307/arrays-for-beginners/page-1

    From my experience I'd recommend trying to keep it XY only if you can, it keeps things simpler. Also it helps to plan out your array on paper or in a spreadsheet.

  • You might also try lerp:

    scirra.com/manual/126/system-expressions

    lerp(a, b, x) Linear interpolation of a to b by x. Calculates a + x * (b - a)

    This should give you the boost you're looking for at the start.

  • There is, and you don't need any trig for it. This will tell you the distance in pixels:

    distance(sprite1.x, sprite1.y, sprite2.x, sprite2.y)

    scirra.com/manual/126/system-expressions

  • 1. If you have the different walls set up as animations, you can use set frame to change which wall you display and compare frame to find out which one is being displayed:

    scirra.com/manual/115/sprite

    2. Instances have a uid (unique id) and iid (instance id, which changes as instances are created and destroyed) that you can query e.g. Sprite_name.uid. (According to the manual, instance ids are "lazily assigned" ^^)

    scirra.com/manual/30/instances

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This tutorial might give you a good place to start:

    scirra.com/tutorials/280/creating-a-memory-match-game

  • If I've understood the question correctly, I think you can do this with a 2 dimensional array.

    Let's say you have a 6 by 4 grid

    Create an array object and set the size x=6, y=4, z=1. Rename the array to be called GRID.

    The data in your array will look like this (remember C2 arrays are zero based so the first row or column is 0 and the highest is (width-1):

    x

    012345

    y

    0 000000

    1 000000

    2 000000

    3 000000

    So now you want to put in a destroyer, which is 3 squares long, (and ship type 1) starting in the top left going horizontally. And a frigate (ship type =2) which is 2 squares long, starting in the bottom right and going vertically.

    You can do this by creating actions:

    GRID Set value at (0,0) to 1

    GRID Set value at (1,0) to 1

    GRID Set value at (2,0) to 1

    GRID Set value at (5,2) to 2

    GRID Set value at (5,3) to 2

    Now the data in your array will look like this:

    x

    012345

    y

    0 111000

    1 000000

    2 000002

    3 000002

    And you can see what ship is where. You can also do error checking to make sure you are not placing a new ship where one already is, and update the values in the array when a ship gets hit.

    Hope this helps.

  • Hey guys, these are some great tips! Thanks ;) I've started using some of them and it's helping a lot.

  • thebuglepodcast.com

    Listen responsibly ^^

  • Hi all,

    What are your tips and best practices for creating C2 "code"?

    I'm a game designer and not by any means a programmer. I've just decided to restart my strategy game project as my "code" is too complicated and messy and it's not all working as I want it to. So I'm making a clean file and rebuilding. It seems like a good time to take stock of what I've learned.

    Best practices

    • Write a clear design document (e.g. in word)
    • Start small and simple (e.g. with small arrays)
    • Test often (e.g. show array variables in a text box on screen to figure out what is / isn't working)
    • Put complicated or repeated code into functions and call these from the main body of the code (less messy and less redundancy)
    • Save a new version of the project often so you can go back if you mess something up
    • Give variables a descriptive name
    • Add lots of comments
    • Break down functions to keep them simple (rather have a lot of simple ones than a few complicated ones)
    • I made a spreadsheet to work out where to place elements on screen (it calculates the midpoints)

    Worst practices

    • Build complicated functions (e.g. nested for-loops updating arrays) which then don't work (better to start simple)
    • Resize graphics within C2 (better to create them at the correct size e.g. in paint.net and import them cleanly)

    What do you think? Do you agree with these? What have you learned that we could add to this list?

    Thanks,

    Mike

  • Hi all,

    Does anyone have a .capx file which shows how to import data from a file?

    I've fiddled around with this for hours without success, including reading tutorials and forum posts and trying out plugins.

    What I have managed is to hack together a "json" format in Excel and copy/paste this in using the "Load from json string" into an array.

    I can create json and text files and bring them into the project. But loading from these files into an array just won't work for me.

    So if anyone can help with a .capx showing where I'm going wrong, I'd appreciate it!

    Thanks,

    Mike

Curious Mike's avatar

Curious Mike

Member since 6 Feb, 2013

None one is following Curious Mike yet!

Trophy Case

  • 11-Year Club
  • Email Verified

Progress

12/44
How to earn trophies