Jump to content
  • Advertisement

RaduIulianGabriel

Member
  • Content Count

    19
  • Joined

  • Last visited

Community Reputation

104 Neutral

About RaduIulianGabriel

  • Rank
    Member
  1. RaduIulianGabriel

    Creating a very simple multiplayer game.

    Well, I have no real idea where to start. For the start, do I need to host a server so others can connect to it? if yes, how exactly do I do that? 
  2. Hello. For few months I've been toying around with C++/C#/Java and AS3. I've managed to create some simple games like Pong, Mario-like platformer, Angry Birds - like game, Solitaire, a racing game and few others. I feel confident enough and I would like some indications for creating some online multiplayer games. No, I'm not thinking at games like World of Warcraft/League of Legends or any other similar games, I'm not stupid. I was just thinking at something like 2-players Pong, Tic Tac Toe, 2-player racing game, an online card game and a chess game. First, I was thinking of using Java/Flash to make the games and embed them in a website (would be great if I can use blogspot.com or any other free website creating platforms for testing purposes). No downloadable client, browser based. And second, for the card/chess game I would like some indications about managing player accounts and allow players to save their progress (number of wins/losses, cards color/art all saved to their account which they can access with their username/pass).  I'm doing this for personal-purpose only, and for the start, managing to get pong working online (so I can play it with one of my friends to say) would be a great achievment to me. So, what would be my next step at this moment?
  3. RaduIulianGabriel

    [SDL] Surface following the mouse cursor

    The problem is that I dont understand how can you move a image located at the coordinates 200, 200 to another point a 450, 450. I was thinking to set the x velocity and y velocity or something like that, like in a pong game I've made, but I'm not sure that will work. Is there a mathematic formula or something to get the values for the velocity? EDIT: Maybe I wasn't clear enough but I don't want the ball to instantly appear to the mouse cursor. I want to see it moving step by step, like a car driving towards a destination
  4. Hey! I need some indications for a C++/SDL project. I want to make a surface, a ball image, to follow the mouse cursor. For example I move the mouse to a position then when I press click the ball will start moving towards the mouse cursor until I press click again somewhere else.
  5. RaduIulianGabriel

    Undefined reference to ' '

    It's the first time I'm trying to make something using multiple source files. When compiling I keep getting this error: D:\C++ Universe\Snake\.objs\main.o:main.cpp|| undefined reference to `screen'| D:\C++ Universe\Snake\.objs\main.o:main.cpp|| undefined reference to `event'| D:\C++ Universe\Snake\.objs\main.o:main.cpp|| undefined reference to `event'| D:\C++ Universe\Snake\.objs\functions.o:functions.cpp|| undefined reference to `screen'| My files: declarations.h #ifndef DECLARATIONS_H #define DECLARATIONS_H #include "SDL/SDL.h" extern SDL_Surface *screen; extern SDL_Event event; #endif // DECLARATIONS_H declarations.cpp #include "SDL/SDL.h" #include "declarations.h" SDL_Surface *screen = NULL; SDL_Event event; functions.h #ifndef FUNCTIONS_H #define FUNCTIONS_H #include "SDL/SDL.h" #include <string> SDL_Surface *load_image (std::string filename); void draw (int x, int y, SDL_Surface *source, SDL_Surface *destination); void clean_up(); #endif // FUNCTIONS_H functions.cpp #include "SDL/SDL.h" #include "SDL/SDL_image.h" #include "declarations.h" #include "functions.h" #include <string> SDL_Surface *load_image(std::string filename) { SDL_Surface *loadedImage = NULL; SDL_Surface *optimizedImage = NULL; loadedImage = IMG_Load(("data/images" + filename).c_str()); if (loadedImage != NULL) { optimizedImage = SDL_DisplayFormat(loadedImage); SDL_FreeSurface (loadedImage); if (optimizedImage != NULL) { SDL_SetColorKey(optimizedImage, SDL_SRCCOLORKEY, SDL_MapRGB(optimizedImage->format, 0, 0xFF, 0xFF)); } } return optimizedImage; } bool load_files () { return true; } void draw (int x, int y, SDL_Surface *source, SDL_Surface *destination, SDL_Rect *clip = NULL) { SDL_Rect offset; offset.x = x; offset.y = y; SDL_BlitSurface (source, clip, destination, &offset); } void clean_up() { SDL_FreeSurface(screen); SDL_Quit(); } constants.h #ifndef CONSTANTS_H #define CONSTANTS_H const int screen_width = 800; const int screen_height = 600; #endif // CONSTANTS_H main.cpp #include <SDL/SDL.h> #include <SDL/SDL_image.h> #include "declarations.h" #include "functions.h" #include "constants.h" int main (int argc, char* args[]) { bool running = true; Uint32 time; SDL_Init(SDL_INIT_EVERYTHING); screen = SDL_SetVideoMode(screen_width, screen_height, 32, SDL_SWSURFACE); SDL_WM_SetCaption("Snake", NULL); while (running) { time = SDL_GetTicks(); if (SDL_PollEvent(&event)) { if (event.type == SDL_QUIT) { running = false; } } if (1000/30 > (SDL_GetTicks() - time)) { SDL_Delay((1000/30) - (SDL_GetTicks() - time)); } } clean_up(); return 0; }
  6. RaduIulianGabriel

    Map editor

    Where do you specify the number of each tile?
  7. RaduIulianGabriel

    Map editor

    In mappy you can load the tiles images, and place pictures on the screen. You don't type numbers, you just place the pictures you want to create the level. But I'm not sure how I can export that in the format that I want.
  8. RaduIulianGabriel

    Map editor

    Hey. Not sure if this would be the best place to post this but anyway. I'd like to know if I can export map/txt files using Mappy or any other map editor that will look like this. Example: 3 Tiles clips from a image.png coresponding to a number: tile_1 = 1; tile_2 = 2; tile_3 = 3; And the text file will look like this, every number coresponding to the respective tile. 1 1 1 2 2 2 2 3 1 2 2 2 3 3 2 2 2 2 I can do this in notepad but it takes a lot and also mistakes can be made pretty easy.
  9. RaduIulianGabriel

    [SDL] SDL_image.h

    Are you sure that I shoud use the + . And what about .c_str() after filename? Is not working like you said
  10. RaduIulianGabriel

    [SDL] SDL_image.h

    Hello. What should I modify in my image loading function to be able to load from a specified path. If the .exe is located in Game folder, I'like to load from gfx folder, which is located in C:\Game\gfx . SDL_Surface *load_image(std::string filename) { SDL_Surface *loadedImage = NULL; SDL_Surface *optimizedImage = NULL; loadedImage = IMG_Load(filename.c_str()); //I was thinking at this line if (loadedImage != NULL) { optimizedImage = SDL_DisplayFormat(loadedImage); SDL_FreeSurface (loadedImage); if (optimizedImage != NULL) { SDL_SetColorKey(optimizedImage, SDL_SRCCOLORKEY, SDL_MapRGB(optimizedImage->format, 0, 0xFF, 0xFF)); } } return optimizedImage; } Thx for help.
  11. RaduIulianGabriel

    How to check for collision between objects from 2 classes

    I ended up using a backup with my code, one with SDL_Rect's. I only moved the player-ball collision to the main function and guess what...it worked. Was a very simple solution. Now I'm wondering if I should use you're check_collision algorithm or this one. Anyway, thank you very much for helping me, I will add the game to this post when is ready in case any other amateur SDL programmer gets in trouble:) Player player1; Player player2; Ball myball; if (check_collision(myball.ball, player1.char1)) { if ((myball.xVel == - BALL_SPEED) && (myball.yVel == BALL_SPEED)) { myball.xVel = BALL_SPEED; myball.yVel = BALL_SPEED; } else if ((myball.xVel == - BALL_SPEED) && (myball.yVel == - BALL_SPEED)) { myball.xVel = BALL_SPEED; myball.yVel = - BALL_SPEED; } } if (check_collision(myball.ball, player2.char2)) { if ((myball.xVel == BALL_SPEED) && (myball.yVel == - BALL_SPEED)) { myball.xVel = - BALL_SPEED; myball.yVel = - BALL_SPEED; } else if ((myball.xVel == BALL_SPEED) && (myball.yVel == BALL_SPEED)) { myball.xVel = - BALL_SPEED; myball.yVel = BALL_SPEED; } }
  12. RaduIulianGabriel

    How to check for collision between objects from 2 classes

    I'm now realizing that my biggest mistake is using void Ball::move, I can either make a simple void move() function or I can type the collision code directly in main. I will start to rewrite my program but I will probably be off soon, so I'll post a reply tommorow. Thx for helping me, check back on this thread in 12 hours if I still have problems to fix. EDIT: How can you use in the collide code variables from 2 classes but with same name? like first x is x and second x is x again?
  13. RaduIulianGabriel

    How to check for collision between objects from 2 classes

    So in Player class, I have SDL_Rect char1 and Player(), in Player() i have char1.x, char1.y , velocity and height + width. So when doing Player char1 I still cant acces de data from Player() - at least that's how i'm thinking EDIT: Maybe you can update one of yours 2d games with collision between 2 object from 2 classes. I may adapt it to my code aswell.
  14. RaduIulianGabriel

    How to check for collision between objects from 2 classes

    The problem is still there. I can't access char1 from Player class because I'm not checking for collision in that class, I'm doing it in Ball class (in void Ball::move). And char1 is not a constant value so I can't put a number instead of that variable.
  15. RaduIulianGabriel

    How to check for collision between objects from 2 classes

    Can you give me some indications of how to merge Player and Player2?And yes I suck at classes so how can I: "You can add public functions to access the SDL_Rect that can then be used from outside the class to test for collisions." ? Thx in advance for helping me
  • 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!