Programmer557

Members
  • Content count

    15
  • Joined

  • Last visited

Community Reputation

124 Neutral

About Programmer557

  • Rank
    Member
  1. I already know that I can use VC++ to create games, and I'm fairly sure that I'm not allowed to actuall SELL the games that I make with it, but If I were to just make a game and release it on a site like GameJolt for free, would that break any rules with VC++?   I've only started thinking about this recently, and I'm probably going to switch to something like CodeBlocks soon, but I want to make sure if I need to switch for a small indie game.   Thanks in advance for your input
  2. Why isn't this moving?

    Thank you very much.  With some slight modification, my program is now working how I want it to.  Thank you also, everyone else who posted.
  3. Why isn't this moving?

    All right, I've made these slight changes and the sprite moves now, but it will only move down, and it will not move more than once.  The message "You Cannot Move Here" also appears.  This isn't supposed to happen unless the player is at the edge of the screen and tries to move in the direction of the edge.  Here is the altered code:     if (SDLK_UP) { if (PlayerLocationy == 0) { Message = DeniedMessage; ApplySurface((ScreenWidth - Message->w)/2,(ScreenHeight - Message->h + 420)/2,Message,Screen,NULL); Message = NULL; } else { PlayerLocationy = PlayerLocationy - 42; ApplySurface(0,421,Sprites,Screen,&TextBox); } } if (SDLK_DOWN) { if (PlayerLocationy == 378) { Message = DeniedMessage; ApplySurface((ScreenWidth - Message->w)/2,(ScreenHeight - Message->h + 420)/2,Message,Screen,NULL); Message = NULL; } else { PlayerLocationy = PlayerLocationy + 42; ApplySurface(0,421,Sprites,Screen,&TextBox); break; } } if (SDLK_LEFT) { if (PlayerLocationx == 0) { Message = DeniedMessage; ApplySurface((ScreenWidth - Message->w)/2,(ScreenHeight - Message->h + 420)/2,Message,Screen,NULL); Message = NULL; } else { PlayerLocationx = PlayerLocationx - 42; ApplySurface(0,421,Sprites,Screen,&TextBox); } } if (SDLK_RIGHT) { if (PlayerLocationx == 378) { Message = DeniedMessage; ApplySurface((ScreenWidth - Message->w)/2,(ScreenHeight - Message->h + 420)/2,Message,Screen,NULL); Message = NULL; } else { PlayerLocationx = PlayerLocationx + 42; ApplySurface(0,421,Sprites,Screen,&TextBox); } } if (SDLK_ESCAPE) { Message = EscapeMessage; ApplySurface((ScreenWidth - Message->w)/2,(ScreenHeight - Message->h + 420)/2,Message,Screen,NULL); if (SDL_KEYDOWN == SDLK_y) { QUIT = true; } } I noticed that Khatharr had said something about not repeating the same functions, but I don't know how to do that quite yet.
  4. Why isn't this moving?

    I found a little bit later that I had forgotten to flip the screen, but even after adding that the program still doesen't do what I want it to.  Just thought I'd add that before anyone made the comment.
  5. Why isn't this moving?

    I am trying to create a program that will randomly generate rooms as the user presses the arrow keys, and it's been working fine, but I've hit a bit of a snag.  I'm trying to get the key press commands working, but no matter how long I look at the code, I can't figure out why the little figure I have made isn't moving.   I've included the entire file for the program, but here is where I think the problem is taking place:   while(SDL_PollEvent(&Event)) { if(Event.type == SDL_KEYDOWN) { if (Event.key.keysym.sym) { if (SDL_KEYDOWN == SDLK_UP) { if (PlayerLocationy == 0) { Message = DeniedMessage; ApplySurface((ScreenWidth - Message->w)/2,(ScreenHeight - Message->h + 420)/2,Message,Screen,NULL); Message == NULL; } else { PlayerLocationy =- 42; ApplySurface(0,421,Sprites,Screen,&TextBox); } } if (SDL_KEYDOWN == SDLK_DOWN) { if (PlayerLocationy == 378) { Message = DeniedMessage; ApplySurface((ScreenWidth - Message->w)/2,(ScreenHeight - Message->h + 420)/2,Message,Screen,NULL); Message == NULL; } else { PlayerLocationy =+ 42; ApplySurface(0,421,Sprites,Screen,&TextBox); } } if (SDL_KEYDOWN == SDLK_LEFT) { if (PlayerLocationx == 0) { Message = DeniedMessage; ApplySurface((ScreenWidth - Message->w)/2,(ScreenHeight - Message->h + 420)/2,Message,Screen,NULL); Message == NULL; } else { PlayerLocationx =- 42; ApplySurface(0,421,Sprites,Screen,&TextBox); } } if (SDL_KEYDOWN == SDLK_RIGHT) { if (PlayerLocationy == 0) { Message = DeniedMessage; ApplySurface((ScreenWidth - Message->w)/2,(ScreenHeight - Message->h + 420)/2,Message,Screen,NULL); Message == NULL; } else { PlayerLocationy =+ 42; ApplySurface(0,421,Sprites,Screen,&TextBox); } } if (SDL_KEYDOWN == SDLK_UP) { Message == EscapeMessage; ApplySurface((ScreenWidth - Message->w)/2,(ScreenHeight - Message->h + 420)/2,Message,Screen,NULL); if (SDL_KEYDOWN == SDLK_y) { QUIT == true; } } } } if(Event.type == SDL_QUIT) { QUIT = true; } } Any help that could be given would be very much appreciated.  I have a feeling it's something smal like a missing = sign that I can't find, but maybe another programmer would be able to see what I have not.   Thank you in advance -Programmer557   [attachment=15821:Randomized Maze Game.zip]
  6. Undetectable bugs.... yay -_-

    That part appears to be fine. Background and Image are set with LoadImage which returns a heap-allocated pointer. SDL_FreeSurface is necessary to free the loaded images (used correctly in Cleanup()).   Here, you're not actually calling LoadFiles (the brackets are missing). Instead, this code is checking if the function pointer LoadFiles is false i.e. zero, which it isn't of course as it's a valid function.    Thank you very much!  This fixed the problem.  now that the images are loading all I need to do is replace the transparency code and the program will be fine!
  7. Undetectable bugs.... yay -_-

    How do I take care of that?  I may have forgotten to mention that I'm pretty new to C++ so I don't understand how to fix that.
  8. Undetectable bugs.... yay -_-

    I am trying to create a program that is supposed to make specified colors transparent based off of Lazy Foo's 5th SDL tutorial for Windows, Visual c++ 2010 express, but I've run into a problem.  The pictures that I have specified aren't showing up at all.  I have all of the neccesary files where they need to be, and I have checked through the code twice at least, comparing it to previous projects and the tutorial, and looking for my usual mistakes (using == where I should be using =, simple spelling mistakes, ETC.) but I can't find anything.  I may just be dense and am missing a single character somewhere in this code, but I would appreciate any help that can be given.   Thank you for your time, here is the code:     #include "SDL.h" #include "SDL_image.h" #include <string> const int ScreenWidth = 640; const int ScreenHeight = 480; const int ScreenBPP = 32; SDL_Surface* Screen = NULL; SDL_Surface* Background = NULL; SDL_Surface* Image = NULL; SDL_Event Event; SDL_Surface* LoadImage(std::string filename) {     //the image that's loaded     SDL_Surface* LoadedImage = NULL;     //optimized image     SDL_Surface* OptimizedImage = NULL;     //load the image     LoadedImage = IMG_Load(filename.c_str());     //if the image loaded     if(LoadedImage != NULL)     {         //create the optimized image         OptimizedImage = SDL_DisplayFormat(LoadedImage);         //Free the old image         SDL_FreeSurface(LoadedImage);     }     return OptimizedImage; } //apply the surfaces to the screen void ApplySurface (int x, int y, SDL_Surface* Source,SDL_Surface* Destination) {     //temp rect     SDL_Rect offset;     //get the offsets     offset.x = x;     offset.y = y;     //blit the surface     SDL_BlitSurface(Source,NULL,Destination,&offset); } bool Init() {     //initialize SDL     if(SDL_Init(SDL_INIT_EVERYTHING) == -1)     {         return false;     }     //initialize the screen     Screen = SDL_SetVideoMode(ScreenWidth,ScreenHeight,ScreenBPP,SDL_SWSURFACE);     //if screen initialazation failed     if(Screen == NULL)     {         return false;     }     //set window caption     SDL_WM_SetCaption("WOOOHOOO FOR NO BOXES!!",NULL);     //if everything is right     return true; } bool LoadFiles() {     //load the background     Background = LoadImage("Background.png");     //if there was an error     if(Background == NULL)     {         return false;     }     //load the image     Image = LoadImage("Tree.png");     if(Image == NULL)     {         return false;     }     //if everything loaded properly     return true; } void Cleanup() {     //free the background     SDL_FreeSurface(Image);     //free the image     SDL_FreeSurface(Background);     //quit SDL     SDL_Quit(); } int main (int argc,char* args[]) {     //keep the program active     bool Quit = false;     //initialize     if(Init() == false)     {         return 1;     }     //load the image     if(LoadFiles == false)     {         return 1;     }     //apply the surface     ApplySurface(0,0,Background,Screen);     ApplySurface(320,240,Image,Screen);     //flip the screen     if(SDL_Flip(Screen) == -1)     {         return 1;     }     //start the loop     while (Quit == false)     {         //get input         while (SDL_PollEvent(&Event))         {             if(Event.type == SDL_QUIT)             {                 Quit = true;             }         }     }     //free the surfaces     Cleanup();     return 0; }    
  9. Program won't show picture OR stop when told

      This part needs some fixing. Well now the program will close, but the picture still isn't showing up.
  10. Program won't show picture OR stop when told

      This part needs some fixing. oh....  It's amazing that no matter how hard I look I always miss that one little detail.  Thanks!
  11.   I am working through Lazy Foo's tutorials on SDL, and I was on lesson 4 (Event Driven Programming) and everything was going exactly how it should have been going, untill I tried to run my program.  The program would run like it was supposed to, meaning that there were no warnings about improper sintax or missing DLLs or anything like that, but all I was seeing was a blank window pop up.      The program is supposed to show a picture (in my case a tree but that isn't important), and stay open untill I hit the X in the upper right hand corner, but for some reason it's not doing either of those.  Like I said I'm seeing a blank screen, but the program also won't close when told to.  I'm able to close it through stopping the debug, but that's not how it's supposed to work.       I've attached the program file here: [attachment=14025:Events.zip] so that you can see if I've missed something there, and here is the code in case you can't open the files on your computer:       #include "SDL.h" #include "SDL_image.h" #include <string> const int ScreenWidth = 640; const int ScreenHeight = 480; const int ScreenBPP = 32; SDL_Surface* Image = NULL; SDL_Surface* Screen = NULL; //SDL event structure SDL_Event Event; SDL_Surface* load_image(std::string filename) {     //Load Image     SDL_Surface* LoadedImage = NULL;     //Optimize     SDL_Surface* OptimizedImage = NULL;     //load image with SDL image     LoadedImage = IMG_Load(filename.c_str());     //if the image loaded fine     if (LoadedImage != NULL)     {         //create the optimized image         OptimizedImage = SDL_DisplayFormat(LoadedImage);         //free the old image         SDL_FreeSurface(LoadedImage);     }     //return the optimized image     return OptimizedImage; } void ApplySurface(int x, int y, SDL_Surface* Source, SDL_Surface* Destination) {     //temp rectangle to hold offsets     SDL_Rect offset;     //get the offsets     offset.x;     offset.y;     //blit to the surface     SDL_BlitSurface(Source,NULL,Destination,&offset); } bool Init() {     //terminate program if init fails     if(SDL_Init(SDL_INIT_EVERYTHING) == -1)     {         return false;     }     //set up the screen     Screen = SDL_SetVideoMode(ScreenWidth, ScreenHeight, ScreenBPP, SDL_SWSURFACE);     //if the screen failed to start     if(Screen == NULL)     {         return false;     }     //Set the window caption     SDL_WM_SetCaption("Event Test",NULL);     //if everything went fine     return true; } bool LoadFiles() {     //load the image     Image = load_image("Tree.png");     //if there was an error     if (Image == NULL)     {         return false;     }     //if everything loaded properly     return true; } void Cleanup() {     //free the image     SDL_FreeSurface(Image);     //quit SDL     SDL_Quit(); } int main (int argc, char* args[]) {     //make sure the program doesn't terminate immediately     bool Quit = false;     //initialize     if (Init() == false)     {         return 1;     }     //load the image     if (LoadFiles() == false)     {         return 1;     }     //apply the surface     ApplySurface(0,0,Image,Screen);     //update the screen     if (SDL_Flip(Screen) == -1)     {         return 1;     }     //start main loop     while (Quit == false)     {         //get input of some kind         while (SDL_PollEvent(&Event))         {             //if user X's out             if (Event.type == SDL_QUIT)             {                 //quit the program                 Quit == true;             }         }     }     //free the surface and quit the program     Cleanup();     return 0; }       Any help would be apreciated.  Thank you in advance.
  12. Learning SDL... Already a speedbump

    I think I figured out the problem.  First of all, I didn't put a '0' behind the 'return' function.  Usually doing this produced more problems but I'm guessing that the SDL library took care of that.  Secondly, I had to copy the SDL.dll from the SDL lib subfolder to my Debug folder for my program.  Now everything seems to be in order, that being my computer will flash for a second and then go back to the normal screen, as if I had written a program that terminated immediately after opening (which I pretty much did)   In other words thank you all for your help! :D
  13. Learning SDL... Already a speedbump

    The actual error: 1>SDLmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol _SDL_main referenced in function _main Try removing the [tt]SDLmain.lib[/tt] dependency from your project. How exactly would I do that?  I'd say that i'm 'ok' when it comes to the c++ language, but I still don't fully understand visual C++ 2010 express. I'm working on a book about that now but It's a big book and I've still barely cracked it.
  14. Learning SDL... Already a speedbump

    I am following Lazy Foo's tutorials for SDL in Visual C++ 2010 Express (http://lazyfoo.net/SDL_tutorials/lesson01/windows/msvsnet2010e/index.php) and I've followed the instructions to the letter, checking and re-checking to make sure I didn't do anything wrong, but I'm still not able to build the program without it telling me that the build failed.  Here is the code that I have (because while I doubt this will help at all it just might)   #include "SDL.h" void main() {     //Start SDL     SDL_Init( SDL_INIT_EVERYTHING );     //Quit SDL     SDL_Quit();     return; }     What really get's on my nerves is that i'm doing exactly what the tutorial says (and it's the first tutorial to >:( )  but the program isn't working   Here, also, is the project folder.  Maybe I did something wrong there, I'm not sure, but if anyone can help it would be much appreciated.[attachment=13978:SDL.zip]
  15. Can Directx do 2D graphics?

    I know this may sound kind of stupid, but that's what questions are for right?  I know that Directx can handle 3D graphics, but can it ONLY create 3D graphics?  I haven't started learning Directx yet because I still don't fully understand C++, but I want to learn before hand so I can trade up to SDL or something else for a 2D environment when I actually do start.