Asmodean's Recent Forum Activity

  • Thanks,

    I recognize that the name is a little bit misleading- This behavior will not only for a PacMan-Game. It should work for all maze like games where you can build a closed path with a tilemap and enemies who chases you.

    It has not even a top down game. A game with a side view, what has ladders or something like that would do also work.

  • Update:

    I changed the name to 'Simple Enemy AI'. I think that is more appropriate.

    Description:

    A behavior with 6 different modes for chasing or following a target. It based on the 4 different Ghosts of PacMan, so it's a very simple AI. There are only a few things you can adjust.

    Enable or Disable the behavior.

    There are no stop or move actions, you have to use 'set enable' as an action.

    Speed

    How many pixels in one second the object moves.

    reset direction

    This is only an action. Normally the sprite (enemy) would never move backwards. The only exception is if it stuck on a dead end. This should avoid that the enemy is jitter from one direction to another.

    With reset direction you can force to recalculate the directions inclusive backwards. This can be helpful if your enemy should flee for something (like the PacMan Ghost when PacMan gets a pill). It could be very bad if the enemy have to move to the next cross-way , before change the direction.

    get direction

    The direction the sprite is moving at this moment.

    1= up; 2=right; 3=down; 4=left;

    Helpful for the animation of the sprite.

    getpx, getpy are for debug ignore them.

    chasing mode

    For each chasing modes you have to set different links to other objects. This are all actions that you should put in 'On start of Layout'.

    All need a Tilemap with a path of tiles to follow. It's up to you how the path looks and the size of the tiles, but this has a big influence of how good the AI works. The tiles have not to be transparent or on the top layer. You can also put the layer as bottom layer. There is no need that this layer is visible at runtime. If you put at at the bottom this could have a positive effect to the performance if you have a really high resolution and a big tilemap.

    The other objects are all sprites:

    Target - The one that should be attacked.

    Hideoutt - It's like the second Target, but more for retreat.

    Cohunter - It's only needed for the encircling mode, best is to use a sprite with the follow mode.

    I recommend to use not an instance of the main enemy sprite but rather a new sprite-object.

    It will only choose the first instance of objects, so it could be possible that the cohunter is the same instance like the main hunter (enemy).

    The modes are:

    retreat and follow

    This are practical the same.The enemy follows direct their target. The difference is that you can give each mode a different target, then you can switch targets at runtime. You could do the same if you switch the target in one of the modes at runtime. It's up to you how you do that.

    Needs:

    A Tilemap and a Target.

    ambush

    Tries to get in front of the target.

    Needs:

    A Tilemap and a Target.

    encircle

    Needs a second sprite as a 2nd hunter and tries to encircle the target.

    Needs:

    A Tilemap, a Target and CoHunter.

    shy away

    Will follow the target, but if it get too near (6 tiles in every direction) it will flee to his second target.

    Needs:

    A Tilemap, a Target and hideout.

    guard

    The opposite of 'shy away'. Guards a target by circling around it. If an sprite comes too near (6 tiles in every direction) it will attack this sprite as long as the sprite is in 6 tiles range.

    This behavior allows only 90° turns.

    If you forget to link a needed object for the mode the sprite won't move.

    This is a first beta. It's highly possible that this behavior causes crashes. So be very careful and don't use it in big projects. It's more for testing at the moment.

    In the example you can see how to use the behavior.

    Put the behavior (only 'simpleenemyai') in: Program Files\Construct 2\exporters\html5\behaviors

    https://drive.google.com/uc?export=down ... 0pJWUstaGs

    obsolet:

    A behavior with the 4 AIs of the 4 different Ghosts of PacMan: Blinky (red), Pinky(pink), Inky(light blue/turquois), and Clyde (brown).

    It uses a tilemap as path for chasing a target. Each Ghost has a different way to chase his target.

    Blinky:

    Chases his target direct.

    Pinky:

    Tries to perform an ambush.

    Inky:

    Inky uses Blinky to encircle his target.

    Clyde:

    Chases his target like Blinky. If he comes to close to his targets, he flees.

    This based all on the work of Toru Iwatani in 1980. It's not really an AI. All Ghost have more or less a simple behavior to chase PacMan. So it looked more like chaos than really an intelligent chase. The advantage is the very low cpu usage.

    A made a little demo to show how the ghost are chasing PacMan. PacMan hasn't really an intelligent behavior. This will only show how the ghost chases. So no collision detection is implemented.

    https://www.scirra.com/arcade/other-gam ... test-19126

    At the moment it's in a very early stage, so no download link. If is there any interest in this behavior I will made a usable version.

  • If two objects collide it should only destroy one of this objects not all instances. It depends of your action which object gets destroyed.

    The event should look like:

    Ball | On collision with Box -> Box| Destory.

  • [quote:2uv33caq]

    i was wishing when grid is 6 then wants to enlarge chr height & width

    but is their any alternative way??

    I don't see any way to do it direct. The not so elegant way would be to make several Spritefont-Grids with different grid sizes and make the one visible you want.

  • I made another example with 36 instances of one sprite. If you have 36 different sprites or other objects not instances you have to put them in a family. That should work also. I didn't test that.

    You can delete the sprites if you put it to a position outside the layout or destroy them.

    https://drive.google.com/uc?export=down ... WU5bVhCaHM

    The character height and width in the spritefont properties is to define the spritefont itself, not to change the size. If its that what you want you have to use scale.

    I don't think it's possible to change the height and width properties with an event. This properties are the real height and width of the spritefont you need that to display it. You can't load a spritefont in an event, so it's not necessary to change this properties with an event.

  • It's that what you're looking for?

    https://drive.google.com/uc?export=down ... lNxOVN5UWM

    Hope that works. Feel free to ask if something is unclear.

  • Only an idea may be is nonsense, have you tried to update webview in Google Play?

  • The Media Feature Pack installed the missing dlls. If it's still not working it could be that MS changed something. What error do you get now?

  • You need the Media Feature Pack for Windows 10.

    https://www.microsoft.com/en-us/downloa ... x?id=48231

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • As far as I know, C2 is designed for exporting Javascript only. Also all plugins/behaviors are written in Javascript. Javascript is a highly dynamic language, means that for example a variable can take a number or a string at runtime. This isn't possible in language like C or C++. In this languages a variable is bound at compile time to a distinct type like string, float, integer ....

    So it's very hard to translate Javascript to C or C++ , the other way around is possible.

    So if you want other exporters you have to rewrite Construct.

  • I dont want the sprite 2 to be in the game and viceversa, what you're teaching me works like that? or both sprites will be in the screen?

    There are both sprite at the same time on the screen in my example. There are several possibilities to have only one sprite at the time on the screen. You can put one sprite outside the layout, make it invisible or destroy it and create a new one every time you switch. I't depends what you want to achieve.

    If it is regardless which position the sprites are after switching make them invisible. If you want to switch positions of the sprites set Sprite1 on position of sprite2 and then sprite2 outside of the layout and vice versa.

  • Be sure that that the else follows direct after the previous event and not as a subevent. It doesn't work with triggered conditions (the one with the green arrow).

    Run if the previous event did not run. Note that this condition does not pick any objects: if it follows an event that picks objects, in the Else event all instances revert to picked again. Else can only follow normal (non-triggered) events. It can also follow another Else event with other conditions to make an "if - else if - else" chain.

    https://www.scirra.com/manual/124/system-conditions

Asmodean's avatar

Asmodean

Member since 31 Jul, 2015

Twitter
Asmodean has 9 followers

Trophy Case

  • 9-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • Popular Game One of your games has over 1,000 players
  • RTFM Read the fabulous manual
  • Great Comment One of your comments gets 3 upvotes
  • Email Verified

Progress

15/44
How to earn trophies