0 Favourites

I need to know how to..

  • Hey :)

    I am making a terraria-clone, it's just minecraft in 2D. I am a newb to Construct 2, so i need some help to some things:

    1: I don't know how to make the block break when holding down the mouse ON the object, and when you're not holding down the mouse anymore, it will stop breaking. (i got a breaking animation, so when animation is finished; Destroy)

    2: If a block is 5 blocks away from the player, it can't be destroyed. How to make that?

    3: When you scroll with mouse button, then you should select the item in toolbar. I have no idea how to make any of that, lol.

    4: Is it possible to make a random world generation (i don't think so)

    5: Is it possible to make multiplayer available, so that for example, the user download a server.exe and then put hamachi server in a properties file or something. Just like Minecraft.

    Thanks! I hope somebody will help :)

    • sorry my bad english, i'm danish.
    • CX
  • 1 & 2 - Simplified - "if player is overlapping block at offset (5, 0 )" and "toolSelected = axe" and "on mouse click" then start to destroy the block. 5 would check 5 pixels to the right on player, and -5 would check 5 pixels to the left.

    3 - Again, simplified - "if toolSelected = scrollScreen" and mouse down then scrollTo...

    4 - Of course it's possible ;) but right now, just get the basics in before going into advanced stuff like that. Create a prototype level of blocks and get everything working. Procedural generation can be implemented after everything is working. You're wanting to do stuff that seem to be more advanced than your capabilities. I mean, if you can't figure out how to smash a block, then you need to learn all that first. Check out the tutorials on this site. You'll learn loads from those in no time.

    5 - I think there's a multiplayer plugin, but haven't bothered with MP myself so can't really offer advice.

  • Hey, thanks for the answer! I am not planning about doing anything random world generation stuff before i actually finish all the other stuff :), and yes, you're right, i don't really know anything yet, only the simple sheets. And i don't know anything about variables yet..

    When you say "toolSelected" and stuff like that, then you men variables, right?

    • CX
  • Yep variables. I did mention variables in my post but must've deleted that after editing to make it simpler to understand.

    You'd probably have a setup like..

    global constant variable TOOL_AXE = 1

    global constant variable TOOL_SCROLL = 2

    global variable toolSelected = TOOL_AXE

    Then you can test with..

    If toolSelected = TOOL_AXE ..

    It's practically as simple as that ;)

    EDIT> Although, I've simplified with just 2 "tools", you'd group tools together, like if you had a hammer, you'd probably set that to 2 and scroll to 3 or whatever.

    The constant means the variable can't be changed at runtime and makes for easier reading.

    And in the example above, toolSelected would actually just store the value of TOOL_AXE which is 1. It's much easier to read your code (as well as debug) that way rather than..

    global variable toolSelected = 1

    if toolSelected = 1...

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Allright, i will play around with it :) Thank you!

  • You're welcome. Now go read some tutorials! Any problems, ask away. ;)

  • Ok, my friend, now i am much better at using this engine! I love the way it works :D

    But i am stuck, and my brain cant handle it. xD

    I have a setup like this:

    When left clicked on Grass, play breaking animation.

    When breaking animation is finished, destroy Grass.

    Now the problem is that i destroys EVERY grass block that i have pasted in..

    Can you help, procrastinator or someone else?

  • When you left-click on the grass get the UID (unique I'd) for the sprite.

    CurrentUID = grass.uid

    Wheb it us destroyed, select the grass with the uid that matches your CurrentUID and destroy that one.

  • or pick nearest to the mouse cursor !

  • RangerJim got it right.

    Picking closest to mouse cursor wouldn't work. What if the animation finishes and the mouse has been moved elsewhere in that time? ;)

  • RangerJim procrastinator Can you tell me how to do that? Cause i really have no idea, but it sounds great!

  • Typing Game (r115)

    Quickest way of answering you in the short time I have. It's something I wrote for someone else on the forums. It's nothing like what you're doing, but saving the sprite UID and picking a sprite based on that variable is in there, so it may give you some ideas. You know... until someone comes along and answers properly ;p

  • Can someone please explain what i need to do?

  • Can someone please explain what i need to do?

    You'll need to specify WHICH grass you want to destroy. If you do not PICK any specific grass instance, the actions will be executed on all of them.

    Don't really know how you've build your sprites so I cannot give you exact answer. Is breaking separate sprite that is overlaid on grass tiles or is it animation of the grass tile?

    You'll need to specify which grass will be destroyed by picking it. I recommend checking the FAQ thread so you'll understand how picking works :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)