Attack on the Forest

The Partridge Family were neither partridges nor a family. Discuss.
albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Attack on the Forest

Post by albinopapa » August 7th, 2017, 2:35 am

I love urban dictionary, without it I'd be stuck asking about this new newfangled internet speak every few posts from chili et al. I had to look up TL;DR before as well, though I'm guessing it's not new.
Dictionary.com wrote:First recorded in 2000-05; from its use in digital communications
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
Zedtho
Posts: 189
Joined: February 14th, 2017, 7:32 pm

Re: Attack on the Forest

Post by Zedtho » August 7th, 2017, 10:34 am

*gives Chili full credit for the save* I did just recommend you to a friend of mine, though, please forgive me ;-;

I can't say I knew what TL;DR meant until a few weeks ago. I finally figured out what it meant because of the context.

By the way, I think I'm going to log progress here from now on. Just so that I can see what I did in the future.
Last edited by Zedtho on August 7th, 2017, 10:43 am, edited 1 time in total.

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Attack on the Forest

Post by chili » August 7th, 2017, 10:42 am

Haha, just pullin yer noodle mate. Can't wait to get some time to check out what you're doing here :)
Chili

User avatar
Zedtho
Posts: 189
Joined: February 14th, 2017, 7:32 pm

Re: Attack on the Forest

Post by Zedtho » August 7th, 2017, 11:01 am

Will log what I've done in this post, I guess.

Also, I was thinking of buying this book , because I have 33 $ that I get to buy a book with, and I was struggling with how game patterns work (Tile-based systems, basic fighting games, and I dunno I have 33 bucks on amazon why not use it :D). https://www.amazon.com/dp/0990582906
Just checking in here to find out if this book is ok and also asking if I should buy hardcover (for 33 bucks) or kindle version. Just something else I noticed, those customer reviews are shady, all these 5 stars o.O.

Something else, I seem rather scatter-brained. I need more words to express random stuff. (Just look at how many times I use "Also, just, by the way")

For the Changelog!
Pre-Delta (Because I looked up Greek Alphabet in Google)
  • Currently have a "MyVec2" class that I can work on to learn about vectors
  • I've made a User and Entities class that can interact with eachother. (Needs refinement) (Entity or better said Enemy is currently a red square)
  • Added Sprite/Animation Support (Thanks Albinopapa, be sure to check out his post on it)
  • Added some Sprites, still needs everything in the spoiler. Missing Sprites are replaced by white currently. (Not in Albino's version):
  • West-Running animation
  • SouthWest-Running animation
  • NorthWest-Running Animation
    (And the mirrors of these, but that doesn't take long)
  • Added a State Machine (again, thanks Albinopapa for the help)
I shouldn't forget to list what's upcoming either:
  • Add Albino's new stuff to the game.
  • Add the remaining sprites
  • Add Sprites so that I can kill Entities
  • Add the Tower in the middle that is going to be attacked by Entities (Sprites & Class)
  • Change the Entites class to have an Attack Priority (make sprites for them then too)
  • Make different types of Entites (more enum classes? Or am I overdoing this :P)
  • Add the wave-based stuff
    And there's a lot more I can add to this, luckily :D
Quick question here, too:
If I want to have multiple swords for the character (or atleast open the possibility for that) should I have a sword class (with an enum class in it for which type) and have either a separate animation for each sword where the user uses it or one animation for the user that is swinging its hands holding no sword and draw a sword animation ontop of that.

Chili wrote:Just pullin yer noodle
o.O

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Attack on the Forest

Post by albinopapa » August 7th, 2017, 4:25 pm

Zedtho wrote:If I want to have multiple swords for the character (or atleast open the possibility for that) should I have a sword class (with an enum class in it for which type) and have either a separate animation for each sword where the user uses it or one animation for the user that is swinging its hands holding no sword and draw a sword animation ontop of that.
If the swords are going to behave differently, then have different sword classes through polymorphism, or use the enums if you aren't ready for polymorphism. If the swords are going to behave the same, but have different data, then just create a struct for each sword type, and pass the active type to a function in sword or sword constructor. If it's just different sprites with no behavior change and no value changes, load all the sprites for all the swords, create a current sword sprite pointer, and when the user changes swords, assign the address of one of those preloaded sprites to the current sword pointer.

Make the animations for the character and sword separate. You'll still have to draw the different sword animations, but not the character. The other way, If you have 5 swords, you'd have to draw the 8 directions for the charcter for standing, running and fighting times the 5 different swords, minus the three mirrord versions I supoose.

Just to give you a reference, the sprite class and alphasprite class in my project do practically the same thing and I could have used an enum to determine which PutPixel function to call, but they DO have different behavior for their drawing, so I made them different classes with the common stuff in the parent class.

The AnimationController class has the same behavior and can display either solid or transparent sprites, depending on which type were loaded into the frames object passed in. And in Frames, that's why I made the Frames::SpriteType enum, so I didn't have to make separate alphaframes and solidframes classes, they both would have the exact same behavior.

I'm going to try the same approach for the Particles I've been working on for a couple of days.

NOTE: Before you buy the book, check out the link in my tag, Game Programming Patters. There is an online version you can read through and see for yourself if it's worth buy the hard back version or not. I've looked through it quite a few times over the past year, and have found it informative and it's a nice read. The explanations of how to use the different design patterns is clear, and the examples are nice, it's probably just me, but there's not enough depth for grasp the patterns just by reading it. I'm have to practice the crap out of it to get it to sink in. Not the authors fault, I'm sure most people get it the first few times.

Some patterns are easier to understand; Game Loop and Update are both things you're already doing. The strategy pattern ( or close to it ), is pretty much the style that chili has been using for teaching.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
Zedtho
Posts: 189
Joined: February 14th, 2017, 7:32 pm

Re: Attack on the Forest

Post by Zedtho » August 8th, 2017, 8:52 am

I'll get the book then, it'll come in handy. Thanks for answering my other questions too!

User avatar
Zedtho
Posts: 189
Joined: February 14th, 2017, 7:32 pm

Re: Attack on the Forest

Post by Zedtho » September 5th, 2017, 3:16 pm

It's been a while! Nothing new yet, just working on the structure of the code atm. Got a question, though.
I've been trying to figure out how to make a keyboard input switch, something like:
switch(VectorOfAllKeyboardInput) //For statement to loop through all of the currently pressed keys
{
case W:
case A:
//etc....

}

Im mainly here to ask if: 1. Its worth making a switch or I should just use an if tree 2. How to do it if its worth it

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Attack on the Forest

Post by albinopapa » September 6th, 2017, 4:24 am

I think as the framework goes, you have two options worth taking.

1) Use if/else if/else for each key you want to test for

Code: Select all

if( wnd.kbd.KeyIsPressed( 'A' )
else if( wnd.kbd.KeyIsPressed( VK_LEFT )
// and so on for each key
2) Use the Keyboard::Read function to get the current code and state.

Code: Select all

while( !wnd.kbd.KeyIsEmpty() )
{
     const Keyboard::Event e = wnd.kbd.ReadKey();
     switch( e.GetCode() )
     {
          case VK_UP:
          case 'W'
               if( e.IsPress() )
               {
                    hero.MoveUp()
               }
               break;
     }
}
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Attack on the Forest

Post by chili » September 6th, 2017, 9:30 am

You can't switch on the keyboard state because it's not a single integral value. It is essentially a container full of bools.

If you want to run your logic by looking at the current state of keys that are down, use ifs with KeyIsPressed (polling-based input). If you want your game to respond to discrete keyup and keydown events, use a switch with ReadKey() (event-driven input; see papa's example above).

They have their strengths and weaknesses, but generally an event-driven model will give you more flexibility and control.
Chili

User avatar
Zedtho
Posts: 189
Joined: February 14th, 2017, 7:32 pm

Re: Attack on the Forest

Post by Zedtho » February 19th, 2018, 5:27 pm

It's been a while, just want to update some information:
New repo is at https://github.com/Zedtho/Attack-on-TheBeardForest/ (Check the Sprites branch)
I'm still working on the sprites, most of them will probably be reworked.
One question I'd like to ask is why it's so slow in debug mode. I'm aware that debug mode generally is slower but this seems really slow for such a small game, no?

Edit: I've also learnt how subjective art is, because the sprites I've uploaded till now on this page are mediocre, or atleast worse than I remembered them :P

Post Reply