This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-08-03 12:04:14

JDProducers
Scratcher
Registered: 2011-12-17
Posts: 40

How to make a CPU Fighter in a fighting game - movement

I need help making a fighting game called "Trex"
And i need help with making the scipts for a cpu Fighter. It's a simple game just so that he reacts to movements of the player...
For example : If player moves towards the cpu, the cpu will then move toward the player and hit him. If player moves away from the cpu, the cpu will then chase the player.
Somthing like that :3


[img]C:\Documents and Settings\Administrator\My Documents\JDProducers Logo.BMP[/img]

Offline

 

#2 2012-08-03 19:03:47

gamer2012
Scratcher
Registered: 2011-04-17
Posts: 100+

Re: How to make a CPU Fighter in a fighting game - movement

The difficulty of making your desired A.I ultimately depends on the complexity of the sensing. It seems like you always want the A.I to head towards the player. A very simple solution would be to have the A.I sprite always point towards the player and move a certain # of steps. The A.I could then punch the player if it is within a certain distance to the player. [if distance to sprite___< #, perform punch action, costume switch, etc.]. However, it is fairly likely that your fighting game will be platforming-based instead of an over-the-top view. You could have the A.I's x-position change be influenced by the player sprite's x-position, and have the A.I jump if the player's y-position is a certain amount greater than it.


Coming soon: Nothing much 'till Scratch 2.0. Oh, here's one of my classics!  tongue  Square Quest: (You BETTER click here!!! XD)

Offline

 

#3 2012-08-04 19:08:22

Prestige
Scratcher
Registered: 2008-12-15
Posts: 100+

Re: How to make a CPU Fighter in a fighting game - movement

AI is immensely difficult to program to a level where it could beat the player but it is possible. I personally find the best way is to programme ready-made "combo's" into it. Not only will it make the AI seem better, but also it means instead of reacting to the players movements it controls it's own every now and then which makes it seem more natural ( and less robot-like )  tongue


"Don't insult someone until you've walked a mile in their shoes. That way, if they don't like what you have to say, you'll be a mile away and still have their shoes  smile  "

Offline

 

#4 2012-08-04 20:38:05

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: How to make a CPU Fighter in a fighting game - movement

Prestige wrote:

AI is immensely difficult to program to a level where it could beat the player but it is possible. I personally find the best way is to programme ready-made "combo's" into it. Not only will it make the AI seem better, but also it means instead of reacting to the players movements it controls it's own every now and then which makes it seem more natural ( and less robot-like )  tongue

It's not hard to have it beat the player, it's harder to make them between unbeatable and doing nothing.

Basically, you need it to carry out certain actions based on attributes, like distance to player, players velocity(or direction),  health etc. The hard thing is making sure all posibilities result in a move, otherwise it just stands there until a criteria is met. The one you asked for would be simple, as it'd point towards and move towards the player whenever a movement key is pressed(or always)


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

Board footer