GMS 2 How do I make the start of an RPG battle system.

O

OriginalGrim

Guest
I wan't to make an enemy go towards the player when they get to a certain distance near them and when it makes contact with the player takes them to a battle screen with the character and the enemy on screen. I'm going to just attempt this before adding any kind of ui or options to the screen.
 

Slyddar

Member
Take notes, breaking down what you are trying to achieve and work through each step sourcing tutorials or resources, plus working with the manual yourself, and nothing is out of reach. When you do it this way, it becomes more achievable.

Post code you have tried and what you are trying to do in smaller sections, as it will be better for you in the long run doing it like that.

point_distance() will help when you get to it, but there is many steps to what you are asking, hence the concept of learning each part as smaller bits.
 
M

maru_th_undrtkr

Guest
if distance_to_object(obj_Player) < range
{
....
}

...
move_towards_point( obj_Player.x, obj_Player.y, speed );

if collision room_next()

.... that stuff is the first thing that comes to mind, but there are so many other little questions like is it a grid base game. does distance need to be calculated by tiles away? can players move diagonally? are there going to be different players. In that case you need to use a parent object. the thing itself is simple, but when it comes together it gets more complicated since u can do so many different things with it. BTW if its grid based, don't use what I wrote. or do, i mean u have infinite options
 

dannyjenn

Member
Yeah, if you have to ask then you're probably not ready for this.

But you could use a state machine.
Code:
// in enemy:
switch(state){
    case IDLE:
        if(distance is less than whatever){
            state = MOVING_TOWARDS_PLAYER;
        }
        break;
    case MOVING_TOWARDS_PLAYER:
        if(collision with player){
            begin the transition animation
            state = TRANSITIONING_TO_BATTLE_SCREEN;
        }
        break;
    case TRANSITIONING_TO_BATTLE_SCREEN:
        if(the transition animation has finished playing){
            goto the battle screen room
        }
        break;
}
 
Top