SDL movement

This is a discussion on SDL movement within the C++ Programming forums, part of the General Programming Boards category; Now I am trying to get the image to just move off center a little bit by using differant x ...

SDL movement

Now I am trying to get the image to just move off center a little bit by using differant x and y values. But when I run this program the image move off screen in increments. Ironically this is the effect I wanted but, I didn't think I was ready so i was just trying to move image a little bit off center not have it keep moving. So here is my code the problem is that the images keeps moving rather than just blitting onto the screen a bit off center. Not any where in the code do I modify xpos or ypos, that I can tell, so I Dont see why when ever I redraw the screen the image moves.

Stolen Quote: Buttered Toast always lands butter side down and cats always land on their feet, what happens when you strap buttered Toast to the back of a cat?
My Quote: Practice Makes Perfect Nobodys Perfect Why Practice?

I am trying to get the. The image I have to be placed a little off center when the program starts instead it is continually moving to the upper left. Leave whatever color trail it is behind it. The original code I had just displayed and image then when u hit the n key it switched to the next image. Then I decided to play around with the SDL_Rect structures and this started to happen. I am pretty sure the problem is around here:

Stolen Quote: Buttered Toast always lands butter side down and cats always land on their feet, what happens when you strap buttered Toast to the back of a cat?
My Quote: Practice Makes Perfect Nobodys Perfect Why Practice?

I get a seg fault when I try to run your code im not exactly sure why you have two screen modes with the back and the scrn1 but you dont need to setting 2 different video modes is not a good idea. I re-wrote your code to do what you wanted.

Wow thanks that fixxed it. Int the other one the image was moving approx 1 or 2 pixels at a time toward the upper left. Do You know why that fixed it?

I want to make a pong game (but dont think I am ready yet), so could someone explain why I dont want 2 SetVideoMode's? I was under the impression that that was what sets the width and heigth of each screen. So lets say I have a 5 by 5 pixel ball bmp. How would I set a screen just around that ball so I can disp it im the main game/paddle are?

Stolen Quote: Buttered Toast always lands butter side down and cats always land on their feet, what happens when you strap buttered Toast to the back of a cat?
My Quote: Practice Makes Perfect Nobodys Perfect Why Practice?

The way you want to do thing is just blit the bitmap to the screen at its specific location. so you just create an x,y coord I personally like to do this with a struct if iI don't need member functions.

As for the two screen modes well Im not absoluty sure if its bad in the sense that it is going to crash etc. I just know you really shouldn't need two different screen modes for a pong game. What was bad with your code is that you were blitting a screen mode to a screen mode so Im pretty sure thats bad your program just opened and closed on my comp and the was SDL deploy parachute in stderr.txt.

Stolen Quote: Buttered Toast always lands butter side down and cats always land on their feet, what happens when you strap buttered Toast to the back of a cat?
My Quote: Practice Makes Perfect Nobodys Perfect Why Practice?

Stolen Quote: Buttered Toast always lands butter side down and cats always land on their feet, what happens when you strap buttered Toast to the back of a cat?
My Quote: Practice Makes Perfect Nobodys Perfect Why Practice?