GameMaker Studio 2: Tutorial de RPG de ação (Episódio 34: Bombas)

★ Código fonte ▶ https://shaunjs.itch.io/shauns-action-rpg-tutorial ★ Playlist ▶ https://www.youtube.com/playlist?list=PLPRT_JORnIuosvhfax2TQTEmN7OYTcSvK ★ Apoie meu trabalho ▶ https://www. patreon.com/shaunjs ★ Assets & Sprites ▶ http://shaunspalding.co.uk/ARPG_Assets.zip (NOTA: clique com o botão direito do mouse e clique em “salvar como” se este link não funcionar, é um problema do Chrome) Aprenda a construir um RPG de ação tipo zelda no GameMaker Studio 2, começando do nada. Hoje implementamos bombas arremessáveis what go boom. Esses tutoriais são quase totalmente suportados por pessoas maravilhosas via Patreon, clique no link acima para se juntar a eles e acessar esses episódios o mais cedo possível, obtenha acesso instantâneo ao código-fonte de todos os vídeos e muito mais.
source
Instead of typing that whole code where you hit all enemies only once again, you can turn it into a function.
function HitSomething(collisionHistory, _damage, _knockback)
{
var _entityList = ds_list_create();
var _entityCount = instance_place_list(x, y, pEntity, _entityList, false);
for (var i=0; i<_entityCount; ++i)
{
//If this instance has not yet been hit by this attack, hit it!
var _entity = ds_list_find_value(_entityList, i);
if (ds_list_find_index(collisionHistory, _entity) == -1)
{
ds_list_add(collisionHistory, _entity);
with (_entity)
{
if (object_is_ancestor(object_index, pEnemy))
HurtEnemy(id, _damage, other.id, _knockback);
else if (entityHitScript != -1)
entityHitScript();
}
}
}
ds_list_destroy(_entityList);
}
oExplode step event:
/// @desc Hit things
if (!global.gamePaused)
{
image_speed = 1.0;
if (image_index < 4)
HitSomething(collisionHistory, 25, 20);
}
else
image_speed = 0.0;
function CalcAttack(_mask, _damage, _knockback)
{
//Use attack hitbox & check for hits
mask_index = _mask;
HitSomething(collisionHistory, _damage, _knockback);
mask_index = sPlayer;
}
In function AttackSlash(), you have to use CalcAttack(sPlayerAttackSlashHB, 5, 10); instead of the original function call. This way the damage and knockback aren't hardcoded in.
You don't have to pass along collisionHistory, but this way you can give the collisionHistory variable a different name. This only works with arrays and ds lists etc., not with regular variables. Those only go into the function and don't get changed outside of the function.
Instead of doing y -= z in the step event, you can do instance_create_depth(x, y-z, depth, oExplode); in the destroy event.
Did i miss where pEntity had a variable entityShadowMod added?
why my flash doesn't reset. it suddenly happen when i start to learn this vd
on my game when the bomb is ticking the whole screen is red. How do I fix this?
if you're having an error with the with statement on line 16 of the step event of the oExplode its probably because you forget the _entityCount–; at the endish part of the code (that's the problem I had 😛
Another Great tutorial!
Just a quick thing, The List "collisionHistory" is only being destroyed when it's finished the animation, So the Player can potentially leave the room before it happens.
It might be a good idea to delete the list when you're changing the room too!
Here's that step event at 19:50
if (!global.gamePaused)
{
image_speed = 1.0
//HIT THINGS
if (image_index < 4)
{
var _entityList = ds_list_create();
var _entityCount = instance_place_list(x,y,pEntity,_entityList,false);
var _entity = noone;
while (_entityCount > 0)
{
_entity = _entityList[| 0];
if (ds_list_find_index(collisionHistory, _entity) == -1)
{
with (_entity)
{
if (object_is_ancestor(object_index,pEnemy))
{
HurtEnemy(id,25,other.id,20);
}
else
{
if (entityHitScript != -1) script_execute(entityHitScript);
}
}
ds_list_add(collisionHistory,_entity);
}
ds_list_delete(_entityList,0);
_entityCount–;
}
ds_list_destroy(_entityList);
}
}
else
{
image_speed = 0.0;
}
Question, when an enemy gets destroyed near a wall, it freezes and keeps dying. Is there an infinite loop somewhere? I followed the code well. Any ideas?
I have zero experience with coding of any sort, but I've worked through the Platform Tutorial and this ARPG Tutorial over the course of two weeks, and I actually feel comfortable working with GML now! Let it be said, I am absolute proof that someone who's never written a curly-bracket in their life can really learn something from this series. Hoping to start my own project after getting some practice with the mathematics side of things. You're doing the pixel Lords work.
If I skip some tutorials like roll function, will my scripts get in trouble? Because sometimes you edit some scripts
Code at 19:50:
if (!global.gamePaused)
{
image_speed = 1.0;
//Hit Things
if (image_index < 4)
{
var _entityList = ds_list_create();
var _entityCount = instance_place_list(x,y,pEntity,_entityList,false)
var _entity = noone;
while (_entityCount > 0)
{
_entity = _entityList[| 0];
if (ds_list_find_index(collisionHistory, _entity) == -1)
{
with (_entity)
{
if (object_is_ancestor(object_index,pEnemy))
{
HurtEnemy(id,25,other.id,20);
}
else
{
if (entityHitScript != -1) script_execute(entityHitScript);
}
}
ds_list_add(collisionHistory,_entity);
}
ds_list_delete(_entityList,0);
_entityCount–;
}
ds_list_destroy(_entityList);
}
}
else
{
image_speed = 0.0;
}
I love this series and thanks for keeping it going.
I do have a question though: when moving diagonally, there is a slight "jitter" to the character. It's subtle and only exists when moving diagonally. I've checked the code quite a few times and was wondering if anyone had a fix. If you disable the running animation and use the idle animation it is incredibly noticeable. It might have something to do with sub-pixel movement but I don't know if you addressed at some point and I just missed it somehow…
Thanks!
I think U should write a book about development in GMS2. Your tutorials are the best!
please
and i want to make a free crack in a game maker studio 2 and it is error is it is not running the game ;-;
hi I am making a game to game maker studio 2 I broke the game maker studio 2 and I want to uninstall it I just delete the game maker studio and I download it with and it is 'already install click ok to upgrade' and it is not working how to fix this plss tell me
I have a bug where slimes ant pots are drawn behind my character, do you have any clue why this is happening?
https://drive.google.com/file/d/1HBwMK2eLy5PltHsbeIO9OnZ2MARDkPS4/view?usp=sharing
Hey I'm in episode 26 in this series and I still have a simple bug in my game and I don't know how to solve it. If I throw a pot slightly below grass, the grass sprite will be over the pot and not vice versa. Same goes for the slime enemy, my character sprite over rides the slime sprite even if I'm "behind" it
Hi Shaun, I've been following the tutorial through and through as a 30 day project, learned a lot for someone who's never done coding before but I had a question, when enemies die if you run into them as they're dying they will sometimes damage you, is there any way around this?
Thanks a lot Shaun for these tutorials!
Can you make an tutorial where we can safe the game by clicking on an object?
So, when I throw the bomb, it just keeps exploding.
How do I fix this?
Hello, I'm currently on the third part, and my game always crashes after a full walk cycle to the right. It only happened after I updated my character sprite. The walk cycle has the same amount of frames for each cycle, I just cant figure it out.
This is awesome, thank you again so much for this series. I'll be anxiously awaiting to devour more!
If anyone doesn't want to write the step event of oExplode, here it is –
if (!global.gamePaused)
{
image_speed = 1.0;
//Hit things
if (image_index > 4)
{
var _entityList = ds_list_create();
var _entityCount = instance_place_list(x, y, pEntity, _entityList, false);
var _entity = noone;
while (_entityCount > 0)
{
_entity = _entityList[| 0];
if (ds_list_find_index(collisionHistory, _entity) == -1)
{
with (_entity)
{
if (object_is_ancestor(object_index, pEnemy))
{
HurtEnemy(id, 25, other.id, 20);
}
else
{
if (entityHitScript != -1) script_execute(entityHitScript);
}
}
ds_list_add(collisionHistory, _entity);
}
ds_list_delete(_entityList, 0);
_entityCount–;
}
ds_list_destroy(_entityList);
}
}
else
{
image_speed = 0.0;
}
I'm really excited to learn how to have a bomb break bomb specific things like boulders!!!
Yes! Bombs!!!! Thanks!
Seriously dude, thank you for these videos.
Next tutorial: Lamp oil
My game is really coming together, thank you for keeping up the series!
Lamp oil, rope, BOMBS? You want it? It's yours my friend, as long as you have enough Rupes.
Instead of the step event of oBomb, can we use an alarm event instead of changing the value of bombTick each frame?
updated particles tutorial please
I need it. I have so many problems with particles. PLEASE.
Just dropping in to give a quick thumbs up while I'm at work. Will watch when I get back home 😁
Boom !!!