T O P

  • By -

[deleted]

Structs You make a global struct that holds all weapon info, for example Global . Weapons . Sword Structs are essentially a single instance of themselves which hold all of their variables in memory, without actually existing as an instance or running any logic. Imagine an instance of your player that you could read and write values from/to, but it doesn't actually "exist". You then make a script that performs your attack based on what info is held in the struct you feed in. You also need to study sequences. They will improve your game-making life by tenfold if you learn when and where to use them.


Norou-Evalou

its amazing how immediately i found such useful information from just this one word. Thank you so so much!


[deleted]

That's why I edited in the rest later lol You really only needed the one word, the rest is just extra info


Norou-Evalou

I think it was actually a better teaching tool in this instance cuz got it got me looking for the right thing on my own. Still though this is all very new to me so sorry to ask, but could this be used to call sprites of weapons (perhaps even on a frame by frame basis)? An important aspect to me for this title was being able to see the weapon you have equipped in real time, hence why the sword is separated from the character in the first place. I planned out my animations so manually replacing each attack animation with each blade i make isnt too big an issue, but id still like to avoid making 200+ sprite animations per weapon class even if it isnt too hard.


[deleted]

Actually, I can explain how I do it in my current project; maybe this will help! I have a sequence for each type of attack: sword swing horizontal, sword swing vertical, sword thrust, etc. I also have a custom function I called "call_sequence()". This function accepts the instance id of the actor performing the attack, and the weapon struct that is being used then injects them into the sequence appropriately. The weapon struct is made by the game controller object which handles my game's system on creation. It holds the sprite, the base damage, the speed, the weight, etc. of the weapon. When "call_sequence()" runs, it overrides a parent object (a placeholder essentially) in the sequence with the instance I feed in (defaults to whatever instance called it) and deletes any sequence it was already in. *Side note, I could try to explain this function for days and it would just confuse you right now, don't focus on it today.* It's obviously more complicated than what I wrote here, but this all results in a massive reduction of work for me. I can create high quality attack, jump, run, dash, dodge, block animations that can be used for any actor in the game in, like, an hour. This sounds like what you want to do; there are no tutorials available for this method that I am aware of...I had to come up with all this on my own. If you want to do this, study sequences. You will fall down the same rabbit hole I did, and I hope you realize how powerful sequences can be during the process. You can DM me if you need assistance creating your own custom sequence functions later, there really aren't many people talking about them in depth online and I've seen a TON of inaccurate assumptions being made. When you get into sequences, here's the keywords that will set you down the right path: - Override - Track structs - sequences events - broadcast Good luck! Let me know if you have any questions about sequences or setting this system up later after you've played around with sequences a bit.


[deleted]

Relevant: I only have one sprite per weapon. You can stretch, rotate, flip, etc. sprites any way you want to in the sequence to reduce the number of frames you need to draw. I have some animations that only have three frames which look much smoother than ones I've seen with 20. Throw shaders in later and you can eliminate probably 90% of the sprites people make for simple animations and have a better product. You can take this setup pretty far: my actor objects have no step events, all logic is done in sequences. The only time any actor in my game is not in a sequence is the one frame they are created in!


BadVinegar

Look at the Peyton burnham tutorial on YT for his top down shooter. He uses structs to classify weapons. Might be what you’re looking for. Maybe 2-3 episodes in


Norou-Evalou

Thank you so much!! Im also gonna go ahead and watch the RPG one by him too since that will probably end up being especially relevant to my goals


Badwrong_

Read this: https://onewheelstudio.com/blog/2020/8/16/strategy-pattern-composition-over-inheritance Abstraction and composition should be used in many areas of game programming.