How to Make a Top Down Shooter in GMS2! (Part 11: Easy Weapon/Item Pickups and EXPLODING BARREL)
HTML-код
- Опубликовано: 14 ноя 2022
- Support me and these videos on Patreon! / peytonburnham
Wishlist Starcross Starcade! (get used to hearing that!) store.steampowered.com/app/17...
My tweets: / peydinburnham
Rose of Starcross Demo: peytonburnham.itch.io/rose-of...
Discord: / discord
My twitch: / peydinburnham Игры
i've fallen in love with this series
Man, I really enjoy how you go through the though process and what not and we all go through your experience. This is more what I enjoy, and the various coding tricks. I'm more confident at using GMS2 and I can't wait to make a cool game from the foundation I've learned here. Thanks for all the effort, and I look forward to see what more you've got cooking.
That's so awesome to hear! I massively appreciate you going through it and getting a it out of it!
Still here this is my milestone as of today, cant wait to start the new series im really enjoying this venture
27:28 - 28:21 I tried this method instead and it LOOKS like it worked. If there's a problem with doing it this way, please let me know. These things are finicky:
if array_contains(global.PlayerWeapons, weapon)
{
instance_destroy();
}
And thank you so much, Peyton, for making these videos! I would be LOST without you :D
thank you peyton!
Thank you!! ❤
thank you for videos ;)
All of your tutorials are AMAZING!
I was wondering, with the floating code for items, I had already previously had a way to do that, and that was just having the sprites animated with different frames in which I even added a a little shadow underneath, and had set the frame speed from there. Is that not something I should have done?
I haven't noticed any bugs or issues yet, but I'm just not sure if something is going wrong that I am not seeing by having my items float that way...
EDIT:
Well, I do realize now that the float code is a much smoother float than just going through my sprite's frames of animation, but I'm okay with that bit of choppy-ness in my game, at least for now, it fits the theme.
cant you create a shadow object sized depending on the sprite_width?
then just update the position to a location somewhat under the heart
Shaun Spalding has a great video in his Action RPG series about drawing shadows on floating items. Definitely recommend.
Peyton's method is essentially the same thing, but Shaun uses a custom variable "z" in like every object that needs it to draw things "floating."
Basically, you can make a shadow sprite that scales to the sprite_width of whatever object is using it, and just draw that shadow sprite in a fixed position below the object. That way, the object hovers but the shadow doesn't. Doing the hovering in the actual sprite is completely fine, too.
For some reason, now my kill counter does not reset to zero after death. What could be the problem?
When player dies first weapon double.
did you figure out how to fix this?
@@alicemation
I did something like this in the player create event, global.WeaponList.none is a blank weapon I made to act as an empty inventory to start:
starterWeapon = global.WeaponList.none;
starterWeaponGiven = false;
//check if weapon is already in player's weapon list
var _size = array_length(global.PlayerWeapons);
for(var i = 0; i < _size; i++ )
{
if starterWeapon == global.PlayerWeapons[i]
{
starterWeaponGiven = true;
break;
}
}
//gives the starter weapon if they dont have it
if starterWeaponGiven = false
{
array_push( global.PlayerWeapons, starterWeapon );
}
selectedWeapon = 0;
weapon = global.PlayerWeapons[selectedWeapon];
this is probably overcomplicated because I'm new to coding but it keeps all weapons already held on death, and gives the starter weapon if you dont already have it on a new game start
Old comment but in case anyone else is wondering how to solve the problem of the player's weapon list not resetting upon game over:
In the code for your player's death, just use ds_list_empty or ds_list_clear or whatever it is on the global.player_weapons. That way, it clears it out every time.
Edit:
Sorry, I was assuming you were using a ds_list for global.player_guns but we're actually using an array.
To completely empty out the array, go to your player object's "Clean Up" event (make one if you don't have it) and write this line of code:
array_delete(global.player_guns, 0, array_length(global.player_guns));
That will completely empty out the list, so that you can refill it when the game restarts.
for those whose starter weapon (the weapon you chose to be spawned with at first) is doubling when dying, i have found an easy fix:
if !(array_contains(global.PlayerWeapons, global.WeaponList.BlueRod))
{
array_push
(
global.PlayerWeapons,
global.WeaponList.BlueRod,
)
}
in this case BlueRod can be any weapon, depends on what you have picked for your starter weapon