Saving screen before SDL_RenderClear()? - c++

I’m looking to create a a simple 2D RPG game using SDL2.
I’m kind of stuck in terms of using something like a pause screen I’ll give you a quick example of what I’m wanting to do:
-If the character collects a skill point and they press F1 to open the skill tree, after they have chosen the skill tree they return to the game.
How do I return to the game? I’m guessing that to get to another screen I would need to render clear. Would I need to do anything before I render clear to save everything that has rendered and then re-render it kind of thing? Or would I have to constantly update the position of the player in a variable and everything and then just render everything back in?

Related

How to get text input from user and set that text on a 3d object in Qt 3D?

As shown in the picture below, which is taken from dynamic texture qt example, what I want to do is really simple, I want to get text input from the user and display it on a 3d object. I'm using C++ for the logic part of my application (just mentioning this because I don't know whether this animation is completely do-able in qml)
Qt dynamic texture example's image showing what I am trying to achieve
I am trying to create a credit card simulator, my 3d object would be the credit card and I would like to display the user's name and other such details, I would optionally like to add some logo to this credit card, if possible.
How would I go about doing this.
This is what my end 3d animation result should look like Credit card animation
do I understand correctly that you already have this textured credit card animation written in C++ and Qt3D?
So, I assume that you're using a QTextureMaterial for the credit card. This QTextureMaterial has a QTexture2D attached which in turn has a QTextureImage added to it.
I'd suggest you replace the current QTextureImage and subclass QPaintedTextureImage. QPaintedTextureImage allows you to draw the texture completely yourself, i.e. in the update function you first draw the (pre-loaded) standard credit card image using the painter and then on top you draw all the stuff you want to add. Since it's simply a QPainter you then use to paint you can paint anything on the credit card.

Game Interface Design - VBO or Immediate Mode?

I've been developing a 2d RPG based on the LWJGL alongside with Java 1.6 for 3 months now. My next goal is to write all of the non-game-ish stuff. This includes menus, text input boxes, buttons and things like the inventory and character information screens. As I am a Computer Engineering student, I'm trying to write everything on my own (except, of course, for the OpenGL part of the LWJGL) so that I "test" myself on the writing of a simple 2d game engine.
I know that making such things from scratch requires basically mapping textures to quads (like the buttons), writing stuff on them and testing mouse/keyboard events which trigger other events inside the code.
The doubt I have is: should I use VBO's (as I'm using for the actual game rendering) or Immediate Mode when rendering such elements? I don't really know if Immediate Mode would be such a drop on performance. Another point is: do the interface elements have to be updated as fast as the game itself? I don't think so, because nothing is actually moving... Are actual games made like that?
Immediate Mode is more straightforward for the task, you would not need to take care about caching and controls composition/batching. Performance dropoff is not that big, unless you render a lot of text (thousands of letters) with each glyph in a separate glBegin..glEnd. If you don't use VBO anywhere else I would recommend trying it out for text output and doing everything else in easier Immediate Mode.
GUI elements might not change as often as game state does, but there's a catch - you could need to update them each time there's a cursor interaction (e.g. button gets OnMouseOver event and needs to be rendered with a highlight). These kind of events may happen very frequently, so thats why rendering may be needed at a full speed.

Is the traditional update-render-loop method overkill for cocos2d/cocos2dx?

So lets say i'm making a board game. i've got a game board array, my logic needs to check for position and collision detection, thats all fine.
Traditionally using something like directX you would have a game loop, test some logic, update the game board array and finally draw the screen,
but with cocos2dx we don't directly draw to the screen we add sprite to layers, and cocos does the rest!
For instance..
Initialise a game array that represents the game board
Initialise a game object
add objects to the array
update the screen (render the array to the screen)
start game loop
Test for some logic condition
remove object from array
more Test for some logic condition, update object position
add objects to the array
update the screen again
loop
The previous would work fine but i don't need to remove the object from the layer only to update its position and re-render to the screen,
with cocos2d/cocos2dx if i keep a reference to that object i could just move it, and update the array.
I can continue with this approach, but i want to know if i'm missing something.
The game array helps with the game logic and mimics the actual playable area, but i can't help feeling its a bit stone-age.
Can anybody help with this, am i completely missing the plot?
All game engines use an update loop. Without it, you wouldn't be rendering anything.
That said, if your game is entirely user-input driven, you can react to user input events (touches) and only then perform game logic (moving or removing pieces, checking win conditions, update score, next turn).
If you want "new-school" then you'll be looking at a game design tool, not a game engine.
This looks fine to me. The thing to keep in mind is during your game loop you will be able to handle animations that keep the board game interesting. I think that is not overkill, you can always find things to animate.

Making a Game Movie/Story Scene

I am close to finishing my first cocos2d game. Now I want to make a small movie/story to show when the user launches the game app. The game should first show the 15 seconds story (animated story) like in MonsterShooter, JailBreaker, AngryBirds, or the like. When you tap on the story, it takes you to the main menu.
My question is: What to use to make the story? Other than making an actual scene with lots of animations is there any other tool that I can use to create an animated story and embed it to cocos2d layer?
What you need to do is to make a video, you could try with adobe premiere, final cut, Windows Movie Maker, iMovie, adobe after effects (just to name a few), then to play the video use the CCVideoPlayer from cocos2d-iphone-extensions

Board Game using SDL

I am building a board game in SDL and here is the problem I am currently facing.
I have a pawn on square 1 and I roll the dice. Based on the value I get on the dice the pawn moves to another square. I am bale to move the pawn after i read the SDL tutorials online. But the problem I am facing is that after moving the pawn to a new location the old pawn still stays at the old location. The tutorials I found on the internet moves a dot but also refreshes the background to cover up the old dot. But I cant do that as my game board is intricate and there are pawns from other players sitting there.
Is there a way in SDL that I could really move a pawn instead of having to create a new pawn at the new location and covering up the old pawn?
The fundamental concept of sprites: Before you insert the sprite, you save a copy of the original screen content. When you need to remove the sprite, you just paste the stored old content back in.
You will have to process all your objects in the correct order (LIFO) for this to work. Since you'll usually be double-buffered, this happens on the cold buffer, so this isn't an issue.
No, your code will need to be able to redraw that board position with the pawn missing. There isn't any way for the computer to automatically reconstruct what the board should look like without the pawn.
It sounds like your render code is mixed in with your game logic. You ought to separate rendering so that you can redraw the complete game scene with a single function call, which you can then use whenever a visible change is made to the game state.