need simple example for getAnimeIndex usage and more things

You must understand the Game Editor concepts, before post here.

need simple example for getAnimeIndex usage and more things

Postby nightFall16 » Sat Jun 25, 2016 3:41 pm

hello guys .. i need someone to explain to me the usage of animeindex and getAnimIndex function
very very simple and with example.
because i want to make a script for my game to change the idle animation- after releasing the key_right(for example)-
to a deffrent idle according to the walk index
let's say i pressed the right key for 3 sec then the player should be
in the 2end frame of the animation and in this frame his right foot is in the front so i want him to stand deffrently
..and another help please ..i want a simple AI code for enemy called Monster and player (Player) for my 2d version of dark souls the boss is huge so he is slow
just walk and try to hit me and dodge my attacks and thanks

HERE MY VERY LAST GAME I MADE ...i'm not very good but this is my hardest job ever in this program
it's a demo and i'am looking forward to add more
The attachment The Stuck Boy.exe is no longer available
Attachments
The Stuck Boy.exe
(1.58 MiB) Downloaded 182 times
2.JPG
1.JPG
this is the first level demo and the envairoment will be changed it other version
User avatar
nightFall16
 
Posts: 41
Joined: Wed Jun 22, 2016 4:24 am
Score: 2 Give a positive score

Re: need simple example for getAnimeIndex usage and more thi

Postby lcl » Sun Jun 26, 2016 10:52 am

Hello!

Whenever you want to find out how some of the build in variables or functions in Game Editor work, the best place to start is the Game Editor Script Reference: http://game-editor.com/docs/script_reference.htm

All the data is on that one long page, which can be a little difficult to just scroll around. But if you know what you're looking for, you can use your web browser's "search on page" -feature to jump to the correct location on the page. On most browsers, the keyboard shortcut for the feature is either F3 or CTRL + F.

Here's what the Script Reference says about animindex and getAnimIndex:
On the actor variable animindex, the GE Script Reference wrote:animindex: Use animindex(count from 0) to find the actual animation of your actor. Each animation that an actor has has a unique index assigned to it. ( This way you can tell which animation is currently running. )

If your actor has 3 animations, then:

The first animation has animindex = 0
The second animation has animindex = 1
The third animation has animindex = 2

This variable is read only.

On the function getAnimIndex, the GE Script Reference wrote:getAnimIndex: Get the index of an animation in the Event Actor.

Return animation index if success, -1 on error.

int getAnimIndex(char *animName)

animName: a valid animation name in the current Event Actor.

Script Editor Syntax:
getAnimIndex("palette");

Example:
1. Create two Actors: "number" and "myImages".
2. Assign text to the "number" Actor. Use "0" for the text.
3. Assign 3 animations to the "myImages" Actor.
4. On "myImages" Actor, Create Actor >Script Editor
5. Enter the following code:
number.textNumber= getAnimIndex("myAnimation2");

Also, the function getAnimName has a lot to do with these two, so here's its description also:
On the function getAnimName, the GE Script Reference wrote:getAnimName: Get the name of an animation in Event Actor.
Return animation name if success, "" on error.

char *getAnimName(int animIndex)

animIndex: an animation index in the Event Actor.

Script Editor Syntax:
strcpy(text, getAnimName(0));

The usage of the Script Reference page is actually one of the GE Tips I have listed here: viewtopic.php?f=27&t=12526


And here's how I'd go about making that boss AI you described:

  • Make the boss check its distance from the player
    • If within attack range:
      • Make the boss check its x coordinate against the players x coordinate
        • If smaller -> make the boss attack right
        • If bigger -> make the boss attack left
    • If out ot attack range:
      • Make the boss check its x coordinate against the players x coordinate
        • If smaller -> make the boss move right
        • If bigger -> make the boss move left
In that plan there is no dodging of the player's attacks, the way of including that in the plan depends on how the player attacks and how you want the boss to try to dodge the attacks.

I checked your game, it's a nice demo. It's got a couple of animation and movement bugs, but otherwise it seems to work pretty nicely. Good work! :)
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: need simple example for getAnimeIndex usage and more thi

Postby nightFall16 » Tue Jun 28, 2016 8:18 am

hay thanks lcl !! thanks ..that not the demo for the boss game it's a small game to try out what you've told me about controlling animations
the idea of how to boss move seems great i'll give it a try look at my AI example without the syntax form
first i need to monitor every thing that the player do like this
player.x to set the boss movement direction
if player is attacking a variable called Player_is_attacking = true
then if player is running from me (lets say the distance is increasing..i'll try to figure out how to mange this) increase the boss speed and change to run animation or just jump
and then after saving these variables in the draw actor of the boss :
always move to player (depending on the player.x )if player_is_attacking or the player is running
if the player starts to attack a timer called give_him_a Chance for let's say 1 sec min and max is 3 sec(random timer ) if the player is attacking and collide with the boss a real damage is applied to the boss if the collision didn't happen within this time the boss will calculate the player location an jump the other direction trying to dodge
and the boss attacking system is to attack randomly if not getting attacked by the player and if not had to move(player is in the attacking range)
THANKS LCL for your co-op ..i'am realy getting into this software !! :D can you tell me my bugs and how to fix them ?? to improve my skills
User avatar
nightFall16
 
Posts: 41
Joined: Wed Jun 22, 2016 4:24 am
Score: 2 Give a positive score

Re: need simple example for getAnimeIndex usage and more thi

Postby Zivouhr » Tue Nov 08, 2016 12:42 am

Lcl, great tips as usual. I remember reading about your advice in the past and you explain it very well.
City of Rott Game created on Game Editor http://cityofrott.wordpress.com/
User avatar
Zivouhr
 
Posts: 549
Joined: Sat May 17, 2014 2:12 pm
Score: 59 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest

cron