I've never programmed this feature myself but I would go about implementing it as a "DAMAGED" state where the character would temporarily not respond to user input. During this state, the character would display the injured graphic and would move back x amount of pixels. Once the time limit of this DAMAGED state has worn off, the state would transition back into "NORMAL" state. There would be an entering function for when a state is transitioned to or from another state so the normal state would have an enter method so to speak in which it would check what the last state was (in this case DAMAGED) then it would act based on what the previous state was. So for this megaman damaged look, when the state goes from DAMAGED to NORMAL, give the player control of his character again and begin the temporary invincible timer.
Take a look at the Finite State Machine pattern. This might be able to explain it better than I can.
IMHO I would say you should create small applications that focus on one thing before building a 2d platform as your first game. If you want to implement grounds/jumping, I would say create a new project and create a "ground" (Technically if you can create boundaries then creating a ground should be no problem). Have a rectangle jump on your created "ground". After that move onto the next thing you want to accomplish and so on. You'll have a very difficult time creating a 2d platformer if it's your first game and you're still learning C++ as well as SFML. Take a step back and deal with C++ only. Try to complete the Gamedev project 1 in the cpp workshop forum. You'll learn a lot from that. Also take a look at http://gameprogrammingpatterns.com/. I've found those patterns very helpful. In particular, I would look at the type object pattern, the state pattern, and the component pattern. I don't know what exactly your expertise is in programming with C++, but by the sounds of it I think you should give the gamedev project a go before trying to make a 2d platformer.
Tiled is a great opensource tild map making program that you can use to create your levels for the 2d platformer. You should also read up on tiled maps if you don't know what those are. If you want to add physics, you should look into "fixed game loops". I can't go into detail right now but this should be enough to start you off with. I strongly suggest doing the gamedev project 1.
Hello everyone. I've been programming for a few years and have had enough with my brain not grasping Object Oriented Design and creating classes that aren't decoupled. I went back to the beginning and took a look at Project 1 in the CPP workshop (http://www.gamedev.net/topic/409907-c-workshop---project-1/). Now, I created a very loosely coupled class which is good (ignore the fact that there are no error checks and does not sanitize user input)....
....And it follows the Single responsibility rule. The only problem is all the logic for deciding what to do with the user input falls upon the main() code. This in turn results in a nasty looking switch statement that looks to me to be a very very poor way of doing things....
So, what would be the best way of dealing with this?
A) Have the menu class handle the input by somehow creating handlers and attaching them to each menu entry. (I'm thinking of .NET and how for example the button gui item simply has a button.Click() Event that gets triggered. Not sure how to do this event delegation in c++ though)
B) Keep the logic out of the menu class but somehow I would have to clean up that main() code. It looks horrible as it is and I know it's a poor design, but I'm not sure how to fix it.
How would you guys fix this problem? Please keep in mind I want to improve my OOP design skills. Ignore the fact I don't have any error checking and the main() code was created as a draft to test my class. I'm leaning toward answer A to solving this issue but I'm open to how others would do this.
P.S. I'm not a beginner in C++, just can't seem to grasp the design aspect of programming well :/
EDIT: Seems like the code tags don't like my tabs/spacing o.0
Posted by SonicD007
on 09 February 2013 - 10:39 AM
I've been trying to understand fixed time step game loops for about 3 weeks and I'm still having trouble understanding it. I've read http://lspiroengine.com/?p=378http://gafferongames.com/game-physics/fix-your-timestep/ and http://www.koonsolo.com/news/dewitters-gameloop/ multiple times and I still can't wrap my head around it exactly. I understand that we want to render as fast as possible as well as updating the game logic at regular intervals. What I don't understand is why the interpolation value is used in the rendering function instead of the update logic function. Also, what would be the time that I would use to do my actual logic updates? Would it be the dt time (interpolation time) or what? If someone can do a mock up in paint to help me visually see how everything connects I would GREATLY appreciate it. I'm driving myself crazy trying to get this under my belt. Another problem I was having was my timer integer was "overflowing".
(I had a tough time understanding gafferon's tutorial. deWitter and Spiro I understood better)
Thanks for the replies! I'm not too much of a noob as I've been programming on and off for about 6 years but I'm going at an incredibly slow pace. My friend and I decided we would create Tetris->Asteroids->Space Invaders for now. I'm in the bad habit of starting projects and not finishing them but I've still been learning. I'm hoping by having someone else programming with me I won't want to stray away from finishing the projects.
I recently read Head First: Object Oriented Design & Analysis which was a great read. I'm trying to keep the concepts from this book in mind when I program now and I think it's helped a lot so far.
I didn't think of trying to program Pac Man, that should be fun. A maze game would also be fun to make. It could definitely be expanded upon to add traps and monsters, maybe that will be our fourth project!
ApochPiQ, I read that a while back, it motivated me a bit to move my butt haha!
Hey everyone, I was just wondering what games you guys think a programmer should have under their belt. For instance, most people say do a text based game, then pong, then tetris, then ........ so I would like to know what games you guys think should be made and in what order you would do them. If you could list concepts that would be learned from making each game that would also be great.
Hey everyone, I'm writing a simple chess clone and I'm not sure how to implement the diagonal moving. I already made the Pawn, Knight, and Rook, but I'm having trouble on figuring out the diagonal moving through a 2d array. Anyone have an algorithm or guide on implementing diagonal moves? Thanks! (I'm working on the Bishop now)
EDIT: A shower later and I just realized the same way I did the attacking for the Pawn is how I would do the diagonals for the Bishops. Sometimes typing the question out and a nice shower helps get the brain working haha! Thanks anyway!