Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: request : i need help coding for this enemy  (Read 2053 times)

0 Members and 1 Guest are viewing this topic.
request : i need help coding for this enemy
« on: February 17, 2011, 05:16:56 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 167
Ok ill start by saying hi ... I have been working on a 2d fan game(loz: flute of elements) for quite some time now using gm8 pro but I've mostly been working on sprites and a story, because I'm not to good at coding, but I found a pretty good engine n I've been using it to start my game ...I have this enemy tht I have no idea how to make work here's the sheet I did for it , I call it the flower baba

[imgzoom]http://i449.photobucket.com/albums/qq211/moffett1990/flowerbabaanimations.png[/imgzoom]

So all it really does is hides in the ground and when link gets close it comes out of the ground and rotates to what ever direction link is in ....it only attacks in up,den,left,right because I figured tht would be easier to code and sprite :-P...when it dies just the root and head explode then the hole closes up and leave a spot for a seed to be planted  ... can anyone help me with this enemy 
Logged

SMRPG

Re: request : i need help coding for this enemy
« Reply #1 on: February 19, 2011, 04:02:24 pm »
I'll try to write up a process for ya later.
Logged
Re: request : i need help coding for this enemy
« Reply #2 on: February 19, 2011, 04:33:55 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 167
Thanks :-)
Logged
Re: request : i need help coding for this enemy
« Reply #3 on: February 19, 2011, 04:49:29 pm »
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3725
I would suggest you use a FSM. The states in your FSM are Sleep, Wake-up, Wake-down, Prowl, Lunge Attack, Hold Attack, Return Attack and Die. The starting state is Sleep and the ending state is Die. Now I will give you the transitions with the triggers for each state.

Sleep
-> Wake-up       (when distanceLink <= thresSleepDistance)
-> Die               (when HP <= 0)

Wake-up
-> Prowl            (animation end)
-> Die               (when HP <= 0)

Wake-down
-> Sleep            (animation end)
-> Die               (when HP <= 0)

Prowl
-> Wake-down    (when distanceLink > thresSleepDistance)
-> Lunge Attack  (when distanceLink <= thresAttackDistance && Direction == isothetic)
-> Die               (when HP <= 0)

Lunge Attack
-> Hold Attack    (animation end)
-> Die               (when HP <= 0)

Hold Attack
-> Return Attack (time out)
-> Die               (when HP <= 0)

Return Attack
-> Prowl            (animation end)
-> Die               (when HP <= 0)

Die
goes nowhere, because here you destroy the object and leave the hole to plant a seed.


Simple and effective. FSM for the win for such simple enemies.
« Last Edit: February 19, 2011, 09:17:55 pm by Niek »
Logged
Re: request : i need help coding for this enemy
« Reply #4 on: February 19, 2011, 09:05:07 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 167
Thanks! I can try tht out when I get to my computer ... hopefully I figure it all out
« Last Edit: February 20, 2011, 01:59:10 am by Moffett1990 »
Logged
Re: request : i need help coding for this enemy
« Reply #5 on: February 20, 2011, 01:52:42 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 167
Ok Niek so like I said above I'm not to good at coding I can go in and edit coding but figuring coding out myself I can't do ..I'm trying to learn but I'm not catching on to quick..I'm more of a spriter/story write lol .How would I put this into the game with all the sprites in it etc I tried figuring it out but I can't
« Last Edit: February 20, 2011, 01:58:16 am by Moffett1990 »
Logged
Re: request : i need help coding for this enemy
« Reply #6 on: February 20, 2011, 06:56:17 am »
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3725
Well, how you code it is all dependent on how you did the rest of your enemy/player/npc stuff and what Link should be interacting with. Is the baba head, the stem or both. But I can give you pointers as how I would do it. But I suggest that if you do not know how to code, you first learn by reading the Game Maker help files. And especially the part about GML. You also always to have it opened when you are coding, because it provides detailed descriptions of the functions you are going to need.

First you have a basic enemy object. In the create event you define any additional variables like 'state' and in the step and draw events you put the the following line
-script_execute(state, event);

Now use for every state a seperate script. And I shall do the sleep script as example
Code: Text
  1. var distance;
  2.  
  3. switch(argument0)
  4. {
  5. case STEP:
  6.         // here you check whether to go to another state.
  7.         if( HP <= 0)
  8.         {
  9.                 scrFlwrBabaDie(INITIALIZE);
  10.                 exit; //because you don&#39;t want to get further after a state change
  11.         }
  12.  
  13.         distance = point_distance(x,y,     objLink.x,objLink.y);
  14.         if( disctance <= thresSleepDistance)
  15.         {
  16.                scrFlwrBabaWakeUp(INITIALIZE);
  17.         }
  18.         break;
  19. case DRAW:
  20.         draw_sprite( sprFlwrBabaComeUp, 0, x, y);
  21.         break;
  22. case INITIALIZE:
  23.         state = scrFlwrBabaSleep; // you will need to set the state otherwise it will not be executed
  24.         solid = 0               //you probably want Link to run right over him when dashing or something.
  25. }
  26.  
Logged
Re: request : i need help coding for this enemy
« Reply #7 on: February 20, 2011, 12:50:12 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 167
Thanks :-)
Logged
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.184 seconds with 50 queries.

anything