Sucking in and Enemy and Spitting them back out.

0 favourites
  • 4 posts
From the Asset Store
Helping streamers give their viewers more excitement.
  • I have been pouring over the forums and even the "How do I FAQS" (and thanks making those they are all super helpful!) and I haven't been able to find an answer to this. So I do apologize if this topic has come up before.

    I wanted to find out how to create the events and behaviors for a character like Yoshi or Kirby from the old SNES games. The main character ***** in enemy with air or tongue and then that character can be shot back out with each bad guy enemy having different attributes. If you **** in a red turtle shell you spit out fire. If you **** in a blue turtle shell it makes you fly if you **** a yellow turtle shell it gives super speed for examples of different behaviors. And I wanted to be able to aim the turtle shells (or enemies) so you can shoot them back out at angle and bouncing off walls a la Yoshi's Island. I'm still new to this and creating projects to help practice and refine things but I am not a big coder, so I figure it would be easier to ask on here for the help. You guys have done such a good job of clearing up and showing examples so I wanted to ask for assistance.

    Thank in advance!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • A basic version of such a mechanic could be implemented by simply giving enemies an instance variable that holds a descriptive function name. Like "firebreath" for example.

    Now when the enemy is sucked in and destroyed, a variable of the player sprite is set to "firebreath".

    And finally you have your action/attack event or whatever call a function with the name of that player variable. Which in this case is "firebreath" of course.

    This way you have a nice workflow and can simply create the appropriately named functions and have them do the stuff that needs to be done. :)

  • First you will have to set up an event with the conditions for when an enemy can be sucked.

    example:

    keyboard on space down

    system compare two values : distance(player.x,player.y,enemy.x,enemy.y) <= 200

    then you should make the sucking action:

    enemy set position :

    x = lerp(enemy.x,player.x,dt)

    y = lerp(enemy.y,player.y,dt)

    Then you should have an event on enemy colliding with player.

    To make sure the player is sucking you should create an boolean instance variable IsSucking.

    keyboard on space pressed: player set variable IsSucking to true

    keyboard on space released: player set variable IsSucking to false

    enemy on collision with player

    player variable Issucking is true :

    • enemy destroy

    etcetera... (being what PixelRebirth said)

  • Hi ceeBat,

    You can give each enemy an instance variable "type"! Then each time you destroy an enemy you can compare type, and if type = fire -> set attack to fireball (or ice, lightning, etc)!

    If you search the manual for variables, it should help you!

    Good luck with it :)

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