Rafael_Treiber

Members
  • Content count

    16
  • Joined

  • Last visited

Community Reputation

166 Neutral

About Rafael_Treiber

  • Rank
    Member
  1. My First Text Based RPG help

    I hope that by now you should have figured out what your problem is but just to add a few comments, you would greatly improve your code if you learned functions, as Servant of the Lord said. Using that structure you can find where your problem is much easily. Also, learn how to use the debugger from your compiler to see the values of your variables and to see why you are not getting the results that you expect. And lastly, as Chad Smith also said, use the code tags to post your code here. It makes the code much more readable for us here. I also don't know if you used indentation on your code or not but it is another tip to make it more readable. Don't be frightened if you are just starting to code. It seems a lot to grasp just to make a text based rpg but if you follow these tips you will notice how much faster you will find errors in your code.
  2. My First Text Based RPG help

    I am not sure on your problem but one thing that caught my attention was the line eHealth - attack; Did you mean...   eHealth -= attack;   I believe this is your problem.
  3. SDL access violation

    The weird thing is that I got SDL_Rwops to work on MinGW compiler but it always crashes on Visual Studio. My interest in SDL_Rwops is because I was trying to create a packfile to put all my images, sounds, fonts, etc. And for that I was following the code from an old game called I have no Tomatoes and, as I said, it works on MinGW. The problem is that Visual Studio is much faster to write code and much easier to debug. The only little detail is that it does not work . Besides, to use Visual Studio I had to change some things in the code like fopen() to fopen_s(), sprintf() to sprintf_s() and I believe that these comands don't work on MinGW. Anyway, enough of punching on a rock... Could you recomend anything to look up to create my own packfile? I think zlib does that but I am not sure if it is not a little too old. And I know that it is impossible to avoid people from hacking your resources but I wanted a packfile that could not be opened in a simple Winrar or Winzip. If you could recomend any library in C++ to do that, it would be great. Thank you very much for your time and interest.
  4. 0 down vote favorite I have a big program that is causing me access violation when using sdl_rwops. So I decided to create a small program just to test sdl_rwops and it is causing me the same access violation. For what I could see it is being caused because of the fopen_s() part but I could not figure out why. Maybe you guys can find what I am missing. Here is the code: #include "SDL.h" #include < stdio.h > int main(int argc, char *argv[]) { FILE *file; SDL_Surface *screen; SDL_Surface *one; SDL_Rect rect; errno_t err; /* This is the RWops structure we'll be using */ SDL_RWops *rw; SDL_Init(SDL_INIT_VIDEO); atexit(SDL_Quit); screen = SDL_SetVideoMode(640, 480, 16, SDL_DOUBLEBUF); /* Here we get a file pointer to a bitmap */ if ( (err = fopen_s(&file,"penguin.bmp", "r")) != 0) { printf("Couldn't load penguin.bmp\n"); exit(1); } /* This is where we actually create our RWops structure. Here we're instructing SDL to get it from the file pointer we just opened */ rw = SDL_RWFromFP(file, 0); /* SDL_LoadBMP_RW is the RWops version of the old standby, SDL_LoadBMP. This will get the image from the RWops you passed in; in this case the file you've opened */ one = SDL_LoadBMP_RW(rw, 0); // This line calls fopen.c and causes the crash /* Clean up after ourselves */ SDL_FreeRW(rw); fclose(file); /* Haphazard way of getting stuff to the screen */ rect.x = rect.y = 20; rect.w = one -> w; rect.y = one -> h; SDL_BlitSurface(one, NULL, screen, &rect); SDL_Flip(screen); SDL_Delay(3000); }   And here is the portion of fopen.c that causes the crash of the program:   errno_t __cdecl _tfopen_s ( FILE ** pfile, const _TSCHAR *file, const _TSCHAR *mode) { _VALIDATE_RETURN_ERRCODE((pfile != NULL), EINVAL); *pfile = _tfsopen(file, mode, _SH_SECURE); // This line causes the access violation if(*pfile != NULL) return 0; return errno; }   The line one = SDL_LoadBMP_RW(rw, 0); jumps to fopen.c and the line *pfile = _tfsopen(file, mode, _SH_SECURE); in that file makes it crash.   I am using Visual Studio 2012 and the picture is in the same folder as the executable. The SDL.dll and even SDL_image.dll are there too. I found a post in google of the same issue and the person said that when he put the whole path (instead of just penguin.bmp") it would not crash. It did not work for me, crashed anyway. I am starting to think that it may be some SDL initialization issue but I did anything I could find on google and nothing worked. I tryed running in Multi-threaded DLL (/Md), in Multi-threaded Debug Dll (/MDd), tryed running in 64 bits, tyred changing the Subsystem to Windows and to console... everything resulted in the same crash.   The error message is:   Unhandled exception at 0x77888C39 (ntdll.dll) in testrwops.exe: 0xC0000005: Access violation writing location 0x00000014.   Which makes me think of a null pointer. So I even tryed to allocate memory for file and rw with new and malloc but it didnt work also. I pretty much used the same code as this site but maybe it is out of date.   Thanks for any help.  
  5. tile based games

    Quote:Original post by Chad Smith Quote:Original post by Rafael_Treiber Quote:Original post by godsenddeath www.lazyfoo.net is the best C++ /SDL resource i've seen, its a very good site with alot of very useful tutorials Oh yeah! It is very good indeed. I have all those tutorials on my computer. But none of them seem to cover tile based games. This LazyFoo tutorial covers tiling. There is also this, which has helped me. I wish you the best of luck! Chad Thank you very much Chad. I didnt remember that lazyfoo link. And the second link seemed quite interesting to me. I'll take a look.
  6. tile based games

    Quote:Original post by godsenddeath www.lazyfoo.net is the best C++ /SDL resource i've seen, its a very good site with alot of very useful tutorials Oh yeah! It is very good indeed. I have all those tutorials on my computer. But none of them seem to cover tile based games.
  7. tile based games

    Quote:Original post by jamaicandude I would suggest you take a look at Game programming all in one 2nd/3rd edition by Jonathan Harbour it uses C and Allegro game library and will teach you how to make Vertical and Horizontal scrolling games while giving you the basics on game programming theory and design. Thank you jamaicandude. I will take a look at it. But in fact I am using C++ and SDL and not Allegro. But it can probably give me some ideas to adapt to SDL.
  8. tile based games

    Hello guys. I have been quite a while away from the programming because I was having lots of work, but now that things got calm again, I started to make a game. I have always done simple games with few moving images and just some sounds. But now I decided to put all my knowlege together and create the kind of game I like the most: platform games. I still like pretty much the old SNES games like Demon's Crest, Black thorne and games like those. I am creating one similar to those and by the moment I can already make my hero walk through the screens, fall down on holes going to another screen, jump and colide against obstacles. Actually I am having some trouble on saving and loading the obstacles into a file but thats not why I am writing. I just would like to know if tile based games are still created today. I am not making it a tile based games. I just saved my hero in a bitmap, created a background and saved it too and then I created a text file with the coordinates where the hero should colide on the background. I dont know if this is the best way to do it so I looked for tile based games on the internet. I read that mostly of the SNES games were tile based games, including Super Mario Bros. But I also read that they did them like that because they are easier to load and faster too. With the technology they had at their processors at that time, it was the best thing to do. But my question is: is it still the best way to do this kind of game? Are there other technics to do platform games now? I have just found texts about tile based games in flash and I code in C++, so if anyone knows any link to a tile based game explanation in C++, I would appreciate very much. Any link about platform games in C++ would be appreciated as well. Thank you for your time guys.
  9. collision in different screens

    Yes, I forgot to say that I am using Microsoft Visual C++ and SDL. Quote: But look. Your design is going to depend a lot on how much you already know about the language you are learning. If what i've said is way over your head then try to create an architecture that makes sense to you using the techniques that you understand. Since this is a learning project, if it works then it's correct. The process of trying to get it to work and learning new techniques to make the code more simple is really what the project is about. =) You are completely right. I just code for fun and I am doing this kind of game just to learn a little more and because I like this kind of game. :) When I wrote this topic I already had some ideas on how I was going to do this, but I just wanted a little more opinions. And I have already got some more ideas. Thank you very much and thanks for your code. It gave me some more ideas too.
  10. collision in different screens

    Could someone tell me a site related to this topic please? Thank you very much
  11. collision in different screens

    Hmm... nice way of doing it. I am using a similar way but without pointers. I am making something like this: if (player.x + player.width &gt; screen.width) { screencount++; showbackground(screencount); player.x = 0; } It is something like this. But I didn't quite understand what you told me to do. Do you say that i have to do this? class SCREEN { (...)}; SCREEN screen1; SCREEN screen2; SCREEN screen3; So that each creen has its own variables of what is in the screen? I don't think I quite understood you. And I liked your ascii drawing by the way [Edited by - Rafael_Treiber on May 4, 2007 10:12:03 AM]
  12. collision in different screens

    Hello all, I am making a 2D game that I can't say its style. Let me explain. It is that kind of game where you can move around the entire screen, without the background changing at all. And as you reach one of the edges of the screen, the entire background changes and you can travel again through the entire new background till you reach an edge again. I can just remember one name of a game of this kind. It is Black Thorne from SNES. Ok, my game is fine and I have three diferent screens where I can travel around. But I have made some obstacles in the backgrounds. One of them is a closed door, where the player will just be able to get through after he finds the key. And one of the obstacles is a gap that the player must jump over. Ok, I can handle the collisions. They are not a problem for me, but what I want to know is how the collisions in this kind of game are handled. I can create some variables to keep the player away from the door if he has not the key yet. But what will I do when my game has 100 different screens? Will I have to create 100 different variables to keep track of every obstacle? I don't think so. actually, this is a way that i thought about to solve this. The other way that I thought about was saving the informations about the obstacles in a text file and load them at runtime. But I dont quite know what to put in this textfile. How could I organize the information about the obstacles. And in some screens there are more than one... Well, I just want to know if you guys know how is it really done in this kind of game. Thank you for your time.
  13. troubles

    Quote:Original post by Replicon You probably just need to distribute it with SDL.dll (and, depending on what you use, SDL_Image.dll, SDL_ttf.dll, and so on). If it sits in the same directory as the game exe, it should work. Also, try running the game from the command line instead of double-clicking on it - the error message might be helpful (though it's probably some segfault). Shame on you for not producing meaningful error messages on initialization issues :-). Yes, they are on the same directory as I told before. Unfortunatelly I can't run from command line here because it will work. It is working here so they should run it from command line. And unfortunatelly I depend on they good will for this. I did produce an error message, and as I told it is "Error on loading images". But I didnt use SDL_Geterror() because I am just learning SDL and I didn't know about it till now. But what you mean by segfault? What could cause it? Could it happen just on some computers? Thanks for the reply.