Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Everything posted by Johnell

  1. If I decide to use a text editor like vim or emacs for coding, what is the best way to compile a C/C++ program with multiple files? Is makefiles the way to go or is there some alternative?
  2. Johnell

    Building C/C++ project without IDE

    How is it done if I want to link my project to some 3rd party library/framework? If I'm using SDL for instance.
  3. What is the best way to create enemies in a tile based side-scroller game? I can think of 2 different ways. Either manually place enemies on the tilemap or random their position.    If I random their position I have to check for collision. If I manually place them I can make sure they never collide with an object. What's the best way to do this?   I am using http://www.mapeditor.org/ to create my tilemap.
  4. Johnell

    2D scrolling game

    I am gonna make a 2D scrolling game, kinda like Mario. What is the best way to move the screen? Move the player and update the camera accordingly or move the entire screen and let the player stay still?
  5. Johnell

    2D scrolling game

      "I suggest you keep your camera position as the center point of the camera." Hmm, not sure I follow. Isn't the camera view camera.x + camera.width and camera.y + camera.height? Also I'm not sure I entirely understand the difference between world position and screen position.    Say object A and B is at (50, 50)    If I draw them like this:   A.draw(50, 50); B.draw(50 - camera.x, 50 - camera.y);   A will be at (50, 50) within the screen all the time. B will be drawn at (50, 50) world position. Is the coordinates within the screen always the same?
  6. Johnell

    2D scrolling game

    I am currently centering the player this way:   player.draw(playerX - cameraX + (screen.width/2), playerY - cameraY + 240);     This do indeed work, although i'm confused as to why it does. Since playerX = cameraX I am just drawing it at screen.width/2. Say screen.width/2 is 400px. If cameraX is at 800 the player will still be drawn at 400px, yet still be centered in the screen. Why is that?
  7. Johnell

    2D scrolling game

    So instead of moving the player I should move the camera and just center the player in the camera?
  8. Johnell

    2D scrolling game

      I wanna know how I can keep the player centered on the screen while moving him. I need the camera to "follow" the player so the camera's position is updated, but I dont know how I can accomplish this.
  9. Johnell

    2D scrolling game

    I understand how to render objects relative to the camera. I'm not sure how I get the camera to follow the player, while keeping him centered.
  10. What exactly is the standard format of sending and receiving messages through a socket? Send everything as a big string and parse with regex, send everything as binary? What are the format on messages sent with FTP or HTTP?
  11. When should human readable format be used over binary and vice versa? If I want to send multiple variables in readable format, should I use something like XML or JSON to easily parse it?
  12. I'm looking to make a little game project of mine and could use some advices.   I'll be using C++ and i'm aware of both SFML and SDL. Are there any other good 2D libraries out there for C++ that I should know of? Secondly, I wanna learn more about multithreaded programming so I want to make a game that would force me to use this.   Any advices on a game project  and what 2D library to use would be appreciated. 
  13. Johnell

    Multithreaded programming

    What multithreading library would you recommend for C++? POSIX, boost?
  14. Johnell

    Multithreaded programming

    What kind of projects would allow me to focus on multithreading, while still building something?
  15. I recently started learning about socket programming in C/C++. I've done some basic stuff, e.g. client writes something to server and it's then echoed back to the client. Now i've come to the point where i'd like to make a chat application, using these concepts. The idea i'm having is that clients can connect to different chat rooms on the server and communicate with each other. In the chat room you should be able to target another user and they should be able to talk with each other. Now to the problem. I'm not sure which way is the easiest/best way to implement this. For the chat room I thought of when a user writes something, the message is sent to the server and the server then echoes that message to the other clients. Not sure what other options I have. Also some ideas on how to implement the private messaging between clients in a chat room would be great. I am using C++ and unix sockets.
  16. Johnell

    Server/client chat application

    Ok, great. Now to the second problem. Say 3 clients is connected to a chat room. Client 1 want to be able to only talk with client 2. Do the messages between client 1 and 2 also go through the server, or is a separate connection between client 1 and 2 established?
  17. Johnell

    Server/client chat application

    I don't really feel like we're on the same page. I wanna know how the server and clients should communicate. For example, if 3 clients are connected to a chat room and client 1 types something, how is client 2 and 3 supposed to know what client 1 wrote? Does client 1 write the message to the server which then forwards that message to client 2 and 3? Or what approach is the best for this kinda situation? This is what i'm confused about.
  18. Johnell

    Server/client chat application

    Could you elaborate? Not sure what you mean.
  19. Johnell

    Server/client chat application

    Any other ideas on what approach I should take in order to implement the functionality I want? I'd like to do most of the stuff myself, since it's a learning experience.
  20. I am looking to learn more about network programming in c++ and learn more about the different protocols. I'd also like to start on an interesting project which cover these topics, and more. I'd love it if you guys could point me towards some books/tutorials/articles regarding this. I'd also appreciate it if you could throw me some ideas on what project to start with.
  21. Johnell

    Network programming

    Is there anything similar to mac?
  22. Johnell

    First steps...

    Your image is most likely not getting loaded. SDL_Surface * load_image ( std::string filename ) { SDL_Surface * loadedImage = NULL; SDL_Surface * optimizedImage = NULL; loadedImage = SDL_LoadBMP(filename.c_str()); if (loadedImage) { optimizedImage = SDL_DisplayFormat(loadedImage); SDL_FreeSurface(loadedImage); } return optimizedImage; } If your if statement is false you will return a null pointer. Try this: image = load_image("background.bmp"); if(image==NULL)std::cout<<"Failed to load image"; If that message is printed you need to fix the search path for your image.
  23. I've recently started learning c++ and it's going pretty well. So far i've made a couple of console applications. I'm curious of what library/framework i'm supposed to use if I want to make a GUI application in c++? I am aware of SDL and SFML to make games but I don't know what to use if I want to make a simple program with a graphic interface. I have a mac and i'm using Xcode as IDE.
  24. I am trying to load a .bmp image with SDL but i'm not sure were to put the image so it can be found. When I add the file in the project folder and run this code I get the following output in the console: /Users/user/Library/Developer/Xcode/DerivedData/SDLExperiment-dsfnjwhgojekaeehoaipimlpnoqb/Build/Products/Debug The image could not be located due to the following error: Couldn't open hello.bmp [color=#754a2b] #include <SDL.h> #include <iostream> using namespace std; int main( int argc, char* args[] ) { SDL_Surface* hello = NULL; SDL_Surface* screen = NULL; char title[50] = ""; SDL_Init (SDL_INIT_EVERYTHING); screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE); hello = SDL_LoadBMP("hello.bmp"); if (hello == NULL) { cout << getcwd(title, 120) << endl; cout << "The image could not be located due to the following error: " << SDL_GetError() << endl; return 1; } SDL_BlitSurface(hello, NULL, screen, NULL); SDL_Flip(screen); SDL_Delay(2000); SDL_FreeSurface(hello); SDL_Quit(); return 0; }
  25. I'd love to get some help to setup SDL with Xcode 4.2. I can't seem to find a good tutorial that's up to date with this. Help would be appreciated.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!