Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
if point_distance(x,y,player.x,player.y) < 200 and hit == 0
state = “chase”
if point_distance(x,y,player.x,player.y) > 200 and hit == 0
{
state = “idle”
speed = 0 //if too far away, stop chasing
}
if hit != 0
{
state = “knockback”
//Knockback code
}
I hope this helps, let me know if you need any more assistance.
Would you happen to know how to add pauses? For example a two second pause before it enters the chase state again?
When the enemy gets hit:
cooldown = 120 //Or room speed time the number of seconds
In the step event:
cooldown -= 1
if cooldown <= 0
and point_distance(x,y,player.x,player.y) < 200
and hit == 0
state = "chase"
Depending on how you set it up, you may not need to check if hit equals 0 anymore. I am always happy to help. Let me know if I can help you with anything else.
@Almond I'm currently workin on your advice now. Thank you for the help! Would you prefer I add you maybe and message you there for advice?
edit: I also forgot that I could just make sure that the enemy is touching the ground in order to chase, so it's exactly how I want it now. :I haha
"if cooldown = 0 {(your movement code)}"
or
"if cooldown != 0 exit; (your movement code)"
In my player's create I have 'health = 100;'
Enemy throws a bone towards the player's x and y at the time.
In the player's collision with the bone i have 'health -=35;' and 'if health <= 0 {game_restart()}
This means it will subtract 35 from the player's health right?
But when I test it, the player always dies in 1 hit and not the intended 3 hits.
So I'm currently implementing a game over screen. The room is large, but the window only displays a certain amount and follows the player.
I'd like to draw text like "game over, r to restart" where ever the player's display is.
I'm currently using ww = window_get_width(), wh = window_get_height()
draw_text(ww/2,wh/2,"Game Over")
This displays on the top left alignment of the exact window size in the room, but not where the player's screen is.
Is there something specifically for the game window since it is constantly changing?
Edit: References: https://docs.yoyogames.com/source/dadiospice/002_reference/windows%20and%20views/the%20game%20window/index.html
draw_text(view_xview + 32, view_yview+32, "Apples: " + string(apples))
Because you want to have the text displayed in the very centre you will need to make a few adjustment because by default text is create from the top left of the position you set it to. You can use the following code to adjust the alignment of your text.
draw_set_valign(fa_middle)
draw_set_halign(fa_center)
//Your text
draw_set_valign(fa_top)
draw_set_halign(fa_left)
In cases like this it is always a good idea to reset it back to the original once you’re done with it as show here. Hope this helps.
Another question, what do you mean reset the valign and halign back to the original? You mean for a different game?
Some things to remember when using draw gui event, when using drawing codes such as draw_text, 0,0 will be the top left of the view. But when using other codes such as instance_create, 0,0 will be the top left of the room, not the view.
That means: in the draw gui event:
draw_text(32,32,”Hello”)
instance_create(32,32,obj_a)
will be in two different positions.
draw_text(32+view_xview,32+view_yview,”Hello”)
instance_create(32+view_xview,32+view_yview,obj_a)
will also be two different spots, the text will fly off the screen as the view moves.
But:
draw_text(32,32,”Hello”)
instance_create(32+view_xview,32+view_yview,obj_a)
IS in the same spot.
As for the text alignment, by reset I mean setting it back to the default. Changing some things that change how to drawing works will often change it for all objects (such as the text alignment and colour blending), not just the object running the code, therefore you probably want to change it back after you have drawn the things you wanted it to change. In the example I showed you:
draw_set_valign(fa_middle)
draw_set_halign(fa_center)
//Your text
draw_set_valign(fa_top)
draw_set_halign(fa_left)
You can see that it changes back to the default fa_top and fa_left after it has drawn the text. If it didn’t have this and in another object you had something like:
draw_text(view_xview + 32, view_yview+32, "Apples: " + string(apples))
Then some of the text might be drawn off the screen instead of from left of the screen and towards the centre. I hope this clears things up.
So I just managed adding air attacks which the method i used was kind of simple it just took me forever to figure it out and probably will need to be reworked eventually -_-
but a single attack+animation is not doing it for me, how would I go with adding combo/chain attacks?
For a chain attack, one that is just the same button over and over again you can use something like:
countdown -= 1
if countdown < -30
stage = 0 //resets the attack stage if the player doesn’t attack
if keyboard_check(ord("V")) // or your attack button
if countdown <= 0
{
if stage == 0
{
// your normal attack
stage+=1
countdown=30 // or length of attack plus a little gap
}
if stage == 1
{
// your second attack
stage+=1
countdown=30 // Again, the length
}
if stage == 2
{
// lets say this is the final stage
stage = 0 // reset to start the chain again.
countdown=30 // or length of attack plus a little gap
}
}