yoni0505

Members
  • Content count

    19
  • Joined

  • Last visited

Community Reputation

109 Neutral

About yoni0505

  • Rank
    Member
  1. C++ - Is Goto a Good Practice?

    Basically there's no reason to use "goto" unless your code's workflow is incorrect.
  2. SDL vs. SFML

    I know that SFML is much faster then SDL because it's [color=#1C2837][size=2]hardware accelerated. Here is a post about how faster it is in SFML's forum, proving it using some test: [/size][/color] [color=#1C2837][size=2][url="http://www.sfml-dev.org/forum/viewtopic.php?t=43"]http://www.sfml-dev.org/forum/viewtopic.php?t=43[/url] [/size][/color] It shows how significant is the hardware acceleration, it can be over 9000% faster for specific things.
  3. Need some consultation

    is MS3D a good format to use? It seems to support bone animation. There is any other formats like MS3D that I should consider using?
  4. Need some consultation

    I'm thinking about making some game that I thought about few years back. I want to make isometric(?) 3D squad level combat game. 1. So I learned about making 3D models, I picked "Blender" for my modeling software, and I'm not sure which 3D model format I should use. The 3D models I plan to use doesn't need much more then animation with bones, so I'm wondering which format support these things? 2. After researching for few days I'm thinking about using C++ with SFML and OpenGL. I'm wondering, is it a good choice? 3. Should I use a game engine? My focus right now isn't about learning to create games from scratch, but to achieve my goal and create the game. What game engines offers? I've tried to read about some of them and I haven't found what they offer. Does they offer things like SFML do? Help would be appreciated!
  5. Question about OpenGL

    I started to learn OpenGL from an old set of tutorials. While I was browsing the reference pages at OpenGL's website, I noticed some of the functions only exists at the OpenGL 2.1 reference, and aren't listed at the new 4.1 reference. For example glBegin() and glEnd() . So I'm wondering if those, and other functions were replaced at the newer versions of OpenGL, and if so, should I find tutorials for the recent OpenGL version(4.1)?
  6. Is it possible to statically link a specific .DLL file? I'm using SDL and I have to include the SDL.dll file so I have to pick "multi-threaded DLL". I don't want to include the msvcr100.dll with my program, I already saw a SDL program which got the SDL.dll and (Multi-threaded DLL) but doesn't depend on msvcr100.dll . I guess there is some way to statically link specific .dll, yet google didn't reveal me the answer... I tried to link msvcrt.lib but it didn't work... :( So is it possible? [wink]
  7. Skipping functions?

    Quote:Original post by Asem Also take a look at those supposed unrelated functions again. Quote:Original post by Asem Actually I compiled your code and had no problems with it working. It's a message using your block images. I think the re-build thing is what needs to happen. Since it seems you tried that and it didn't work, start another project and copy paste the files over and re-setup the libs. also you need the SDLmain.lib file too. Also your character won't move without the added lines in bold: //set the player's position void movePlayer(int destX, int destY) { player.x = destX; player.y = destY; player.dest.x = destX*32; player.dest.y = destY*32; } Thank you guys, I didn't notice it! [Edited by - yoni0505 on December 14, 2010 9:12:54 AM]
  8. Skipping functions?

    I tried to change the "checkInput" function's call location and it works outside the "while(SDL_PollEvent(&event))" loop, at the "while(running)" loop it works! What can cause such a thing?! Thing is really weird!
  9. couple of questions

    Quote:Original post by ibebrett 2. OpenGL is only used for graphics. It does not handle input. You didn't understand me, I asked if openAL (audio) and openIL (input) are a good choice for other stuff then graphics?
  10. couple of questions

    1. if I got it right, GLUT and SDL are used with openGL in similar way/propose. Which is better to use and what each one capable of doing? 2. I understand that openGL only used for graphics and for input and such you have to use another library. I've saw there is openAL and openIL. Are they good?
  11. Skipping functions?

    It didn't change anything. Perhaps someone more experienced then me can try to find the problem? Here is the full code: *Have to link "SDL.lib" and "SDLmain.lib" (need SDL). *Have to place "SDL.dll" at the .EXE's folder. *Have to place the images for the "graphics" at the poject's folder (pojectname\projectname). code: #include "SDL.h" #include <cstdlib> SDL_Surface *screen; class cPlayer{ public: int x,y; SDL_Surface *image; SDL_Rect src, dest; void setImage(char* file_name) { player.image = SDL_LoadBMP(file_name); player.image = SDL_DisplayFormat(player.image); player.src.x = 0; player.src.y = 0; player.src.w = player.image->w; player.src.h = player.image->h; player.dest.x = x*32; player.dest.y = y*32; player.dest.w = player.image->w; player.dest.h = player.image->h; } }player; class cTile{ public: SDL_Surface *image; SDL_Rect src, dest; }; class cLevel{ public: int map[15][20]; cTile tile[15][20]; void setMap(int map[15][20]) { for(int y=0; y < 15; y++) { for(int x=0; x < 20; x++) { level.map[y][x] = map[y][x]; } } } }level; //set the player's position void movePlayer(int destX, int destY) { player.x = destX; player.y = destY; } //check if a tile is free for the player to move to void isTileFree(int x, int y) { int posX = player.x+x; int posY = player.y+y; int tile = level.map[posY][posX]; switch(tile) { case 0: movePlayer(posX,posY); break; } return; } //check for specific input void checkInput(SDL_KeyboardEvent *key) { switch(key->keysym.sym) { case SDLK_UP: isTileFree(0,-1); break; case SDLK_DOWN: isTileFree(0,1); break; case SDLK_LEFT: isTileFree(-1,0); break; case SDLK_RIGHT: isTileFree(1,0); break; } } //load a .BMP file to the screen void loadBMP(char* file_name, int x, int y) { level.tile[y][x].image = SDL_LoadBMP(file_name); if(level.tile[y][x].image == NULL) { return; } level.tile[y][x].image = SDL_DisplayFormat(level.tile[y][x].image); level.tile[y][x].src.x = 0; level.tile[y][x].src.y = 0; level.tile[y][x].src.w = level.tile[y][x].image->w; level.tile[y][x].src.h = level.tile[y][x].image->h; level.tile[y][x].dest.x = x*32; level.tile[y][x].dest.y = y*32; level.tile[y][x].dest.w = level.tile[y][x].image->w; level.tile[y][x].dest.h = level.tile[y][x].image->h; } //display a BMP image on the screen void displayBMP(SDL_Surface *image,SDL_Rect src, SDL_Rect dest, int x, int y) { SDL_BlitSurface(image, &src, screen, &dest); } //check which image to draw for a tile void loadTile(int tile,int x, int y) { switch(tile) { case 0: loadBMP("tile0.bmp",x,y); break; case 1: loadBMP("tile1.bmp",x,y); break; case 2: loadBMP("tile2.bmp",x,y); break; } } //load a map to the screen void loadMap(int map[15][20]) { for(int y=0; y < 15; y++) { for(int x=0; x < 20; x++) { loadTile(map[y][x],x,y); } } } //display a tile void displayTile(int x, int y) { displayBMP(level.tile[y][x].image,level.tile[y][x].src,level.tile[y][x].dest,x,y); } //display a map void displayMap(int map[15][20]) { for(int y=0; y < 15; y++) { for(int x=0; x < 20; x++) { displayTile(x,y); } } } //update the screen void updateDisplay() { displayMap(level.map); displayBMP(player.image,player.src,player.dest, player.x * 32, player.y * 32); SDL_Flip(screen); } int main(int argc, char *argv[]) { //initialize SDL if(SDL_Init(SDL_INIT_VIDEO) != 0) { return 1; } atexit(SDL_Quit); //set video mode screen = SDL_SetVideoMode(640,480,16, SDL_DOUBLEBUF); if(screen == NULL) { return 1; } //set stuff SDL_WM_SetCaption("Tile Map", NULL); SDL_Event event; int running = 1; player.x = 2; player.y = 7; player.setImage("player.bmp"); int map1[15][20] = { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1, 1,0,2,0,2,0,2,2,2,0,2,0,0,0,2,0,0,0,0,1, 1,0,2,0,2,0,2,0,0,0,2,0,0,0,2,0,0,0,0,1, 1,0,2,2,2,0,2,2,2,0,2,0,0,0,2,0,0,0,0,1, 1,0,2,0,2,0,2,0,0,0,2,0,0,0,2,0,0,0,0,1, 1,0,2,0,2,0,2,2,2,0,2,2,2,0,2,2,2,0,0,1, 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 1,0,2,0,2,0,2,2,2,0,2,2,2,0,2,0,2,0,0,1, 1,0,2,0,2,0,2,0,0,0,2,0,2,0,2,0,2,0,0,1, 1,0,0,2,0,0,2,2,2,0,2,2,2,0,2,2,2,0,0,1, 1,0,0,2,0,0,2,0,0,0,2,0,2,0,2,0,2,0,0,1, 1,0,0,2,0,0,2,2,2,0,2,0,2,0,2,0,2,0,0,1, 1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; level.setMap(map1); loadMap(level.map); //main loop while(running) { //check input while(SDL_PollEvent(&event)) { switch(event.type) { case SDL_KEYDOWN: checkInput(&event.key); break; case SDL_QUIT: running = 0; break; } } //update the screen updateDisplay(); //dalay program SDL_Delay(5); } return 0; } images: http://www.mediafire.com/?wd5bjdsmka0rxhd This is some unique error [depressed]
  12. Lag problem

    Quote:Original post by JasonR Hello. I read through the source code you posted and noticed that you are loading from disk every image to be drawn right before you draw it to the backbuffer. You could increase the speed of the program if you would load your bitmaps only once at the beginning of the program instead of every time the screen is redrawn. Thank you, I'll do it.
  13. Skipping functions?

    I tried both release and debug modes, no difference. The function "checkInput" leads to the function "isTileFree" that leads to the function "movePlayer" that modify a global variable. //check if a tile is free for the player to move to void isTileFree(int x, int y) { int posX = player.x+x; int posY = player.y+y; int tile = level.map[posY][posX]; switch(tile) { case 0: movePlayer(posX,posY); break; } return; } //set the player's position void movePlayer(int destX, int destY) { player.x = destX; player.y = destY; } It worked before I added and changed few things which doesn't effect those functions, could it be somehow related?
  14. Skipping functions?

    Hi. I'm having a weird problem, I'm building a simple game to gain some skill and one of my functions is sort of ignored. I'm using MSVC++ 2010. It used to work before I added and modified some unrelated functions in the code. I tried to put a breakpoint at the functions line, and when I debug I get a empty red breakpoint with a "!" sign that says: "The breakpoint will not currently be hit. No executable code is associated with this line. Possible causes include: preprocessor directives or compiler/linker optimizations." I checked the line that calls the function using a breakpoint and it does stop. the function that doesn't work: (global scope) //check for specific input void checkInput(SDL_KeyboardEvent *key) { switch(key->keysym.sym) { case SDLK_UP: isTileFree(0,-1); break; case SDLK_DOWN: isTileFree(0,1); break; case SDLK_LEFT: isTileFree(-1,0); break; case SDLK_RIGHT: isTileFree(1,0); break; } } and the line that called the function is placed at "main" : //main loop while(running) { //check input while(SDL_PollEvent(&event)) { switch(event.type) { case SDL_KEYDOWN: checkInput(&event.key); break; case SDL_QUIT: running = 0; break; } } //update the screen updateDisplay(); //dalay program SDL_Delay(5); } I'm really confused cause it used to work before.
  15. When to move to OpenGL?

    Thanks for the info. I looked for the documentation and found a nice tutorial for beginners which looks pretty much straight forward. Also I'm experienced with learning from reference pages, I learned few scripting languages this way so I believe it wouldn't be a problem. About the math, there is specific things I need to know? Anything more then x,y,z and sin cos tan?