#ifdef WIN32
#pragma comment(lib, "SDL.lib")
#pragma comment(lib, "SDLmain.lib")
#endif
#include "SDL.h"
;void run()
{
Uint32 move;
move = SDL_GetTicks;
SDL_Rect dest;
move = SDL_GetTicks - move
;dest.x += 100 * move;
dest.y += 100 * move
;}
int main( int argc, char* argv[] )
{
Uint32 move;
;SDL_Init( SDL_INIT_VIDEO );
move = SDL_GetTicks()
;SDL_Surface * screen = SDL_SetVideoMode( 800,600, 24, SDL_ANYFORMAT|SDL_DOUBLEBUF );
SDL_Surface * img = SDL_LoadBMP( "filename.bmp" );
SDL_Rect dest;
dest.x = 100;
dest.y = 100;
SDL_Event event;
SDL_Event a;
SDL_Event b;
SDL_Event Event
;SDL_Rect coord
;coord.x = 200;
coord.y = 500;
SDL_Surface * tdisplay = SDL_SetVideoMode( 800,600,24,SDL_ANYFORMAT|SDL_DOUBLEBUF );
SDL_Surface * imi = SDL_LoadBMP( "ad.bmp" );
SDL_Surface * bckg = SDL_LoadBMP ( "bg.bmp" );
Uint32 now;
;while(true) {
SDL_BlitSurface(img,NULL,screen, &dest);
SDL_PollEvent(&event);
if(event.type == SDL_MOUSEBUTTONDOWN)
{
if(event.button.button == SDL_BUTTON_LEFT)
{
SDL_BlitSurface(imi,NULL,tdisplay,&coord);
SDL_Flip(tdisplay);
;}
}
}
if(event.type == SDL_QUIT)
{
return 0;
}
SDL_Event up;
if(up.type == SDL_KEYDOWN)
{
if(up.key.keysym.sym == SDLK_UP)
{
run()
;}
}
SDL_Flip( screen );
return 0;
}
[Edited by - hplus0603 on September 5, 2004 12:12:14 PM]
What do these errors mean
(10) : error C2440: '=' : cannot convert from 'Uint32 (__cdecl *)(void)' to 'Uint32'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast(15) : error C2296: '-' : illegal, left operand has type 'Uint32 (__cdecl *)(void)'
edit: added proper code tags
move = SDL_GetTicks;SDL_Rect dest;move = SDL_GetTicks - move
SDL_GetTicks is a function, so it should be SDL_GetTicks()
[smile]
(The error says that it can't convert from a function pointer to an integer..)
bah,I always make mistacks like that,but it still wont move.
Do I have to have a game loop to make it work?
Do I have to have a game loop to make it work?
Well, I'm not sure what your intention is with the code I posted above:
Are you sure you want to calculate move like that (it will just be zero all the time)? Wouldn't it be better to make it equal to the time since the last frame instead?
move = SDL_GetTicks();SDL_Rect dest;move = SDL_GetTicks() - move;
Are you sure you want to calculate move like that (it will just be zero all the time)? Wouldn't it be better to make it equal to the time since the last frame instead?
I was trying to help you figure it out for yourself [smile]
You do see why your solution doesn't work, I hope?
Anyway, if you do something like this:
The above will calculate ticks since last frame.
If you add that and send dt to your run() function, and move based on that, it should work better.
You do see why your solution doesn't work, I hope?
Anyway, if you do something like this:
Uint32 lastframe=SDL_GetTicks();while(true) { Uint32 dt=SDL_GetTicks()-lastframe; lastframe=SDL_GetTicks();
The above will calculate ticks since last frame.
If you add that and send dt to your run() function, and move based on that, it should work better.
http://cone3d.gamedev.net/cgi-bin/index.pl?page=tutorials/gfxsdl/index
read lesson 2, it has some beginner information about moving images in SDL.
It is so obvious that he just comes here to waste people's time.
He always does the most stupd things, that no one would ever do. Someone will answer a question of his, with example code, and then he'll will come back and ask an even more stupid question that could have been answered by simply looking at the other code. For example, he will just have been given the code to a simple hello world program, then for his next question he asks "why isn't my code working" and you see in his code that he never closes any of his '{'s, and adds a bunch of other obvious crap that the example code that was just given to him didn't do.
Ahh, you have to look at his profile yourself to see the mistakes that he went out of his way to make. Also, look at this code he just gave... he randomly puts the semicolon preceding the next line instead of at the end of the line.
Just look at his profile.
He always does the most stupd things, that no one would ever do. Someone will answer a question of his, with example code, and then he'll will come back and ask an even more stupid question that could have been answered by simply looking at the other code. For example, he will just have been given the code to a simple hello world program, then for his next question he asks "why isn't my code working" and you see in his code that he never closes any of his '{'s, and adds a bunch of other obvious crap that the example code that was just given to him didn't do.
Ahh, you have to look at his profile yourself to see the mistakes that he went out of his way to make. Also, look at this code he just gave... he randomly puts the semicolon preceding the next line instead of at the end of the line.
Just look at his profile.
i dont think hes a troll. i think hes just trying to do too much at once. (and yes, i remember all his old posts. i think the poor bastard has been trying to move this sprite for months now, lol)
MPG, i think you should go back to learning the basics of C++. start small, making a text or ASCII based game. then try to move on to SDL following cone3d or other tutorials. if you have problems with simple C++ logic, then you shouldnt be trying to do graphics. good luck.
MPG, i think you should go back to learning the basics of C++. start small, making a text or ASCII based game. then try to move on to SDL following cone3d or other tutorials. if you have problems with simple C++ logic, then you shouldnt be trying to do graphics. good luck.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement