• Advertisement

sandorlev

Member
  • Content count

    34
  • Joined

  • Last visited

Community Reputation

193 Neutral

About sandorlev

  • Rank
    Member
  1. Hey GD!   I was thinking about implementing an online server-client game and here is what I came up with: 1. The game is driven by events (if a player gets shot, an event is generated, etc). 2. The event is converted to some sort of format and sent to the server. 3. The server sends it back to all clients but the original sender. 4. The clients convert it back and make the necessary changes in game logic.   Does that sound like it could work? I haven't been able to think about a better solution myself.   Now the real question is (if my solution makes sense), what format should I use to send my event classes through UDP sockets? Should I just convert their data to strings? Are there popular solutions to this?
  2. Co-op RPG

    Hey guys!   I'm a huge fan of the Diablos (yes, even Diablo III), and I have always wanted to make an isometric RPG. I already got some of the basics down, most importantly the basic map handling, just waiting for SDL 2.0 to come out so I can get it running on decent fps. Now, I've been thinking about making it an online game (as in anyone can make a game and 1-2 others can join). Would it take huge efforts? I have no experience in C++ socket programming, even though I figured I could just learn SDL_net.   Would I need to code everything with respect to multiplayer, or can I just add it later through some hacking?
  3. I didn't read the whole thing yet, but it seems pretty awesome!
  4. Rendering a 40x40 tilemap that has ~10 layers in SDL 1.2 is pretty darn slow, I started looking into faster options. Now my question is, is SDL 2.0 a lot faster than 1.2? I'm trying to avoid using OpenGL as best as I can, but if it's the only efficient way to render quickly, I'll probably have to use it. Any opinions on SDL 2.0 concerning speed?
  5. I'm trying to render a map with a moving camera and I get a segmentation fault every time I start moving down. Here is the code: [CODE] void Map::Render(SDL_Surface* tileSet, SDL_Surface* display) const { const int tileSize = Tile::GetTileSize(); Vector2D cameraLocation = Camera::control.GetLocation(); //Checking boundaries if (cameraLocation.x < 0) cameraLocation.x = 0; else if (cameraLocation.x > width * tileSize) cameraLocation.x = width * tileSize; if (cameraLocation.y < 0) cameraLocation.y = 0; else if (cameraLocation.y > height * tileSize) cameraLocation.y = height * tileSize; Vector2D first; first.x = (int)cameraLocation.x / tileSize; first.y = (int)cameraLocation.y / tileSize; Vector2D offset; offset.x = (int)cameraLocation.x % tileSize; offset.y = (int)cameraLocation.y % tileSize; for (int y=0; y<height; y++) { for (int x=0; x<width; x++) { //Segmentation fault happens here const int index = \ rows[y + first.y].columns[x + first.x].GetTileID(); Rectangle srcRect = Tile::GetSourceRect(index); const int xOffset = x * tileSize - offset.x; const int yOffset = y * tileSize - offset.y; Surface::Blit(xOffset, yOffset, srcRect, tileSet, display); } } } [/CODE] The segmentation fault happens at the GetTileID() function. Additional data: [CODE] width = 50; height = 200; tileSize = 96; //Variable values when the segmentation fault happens cameraLocation.x = 10; cameraLocation.y = 100; first.x = 0; first.y = 1; offset.x = 10; offset.y = 4; x = 9; y = 198; xOffset = 854; yOffset = 19004; [/CODE]
  6. Decent 2D isometric tutorial?

    I've been searching the internet for literally weeks and I haven't been able to locate a decent 2D isometric tutorial or book. Yes, I've read multiple articles here on gamedev, but they're either really old or they don't go into specifics at all. What I'm looking for is one that: - is recent (not older than ~3-4 years) - is preferably in C++ - covers basic tile attributes - covers basic pathfinding - covers camera movements. Looking forward to your suggestions!
  7. C++ falling asteroids

    [quote name='KnolanCross' timestamp='1353948332' post='5004230'] Oh sorry, complety missunderstood what you said. In this case I believe you need something like this: [source lang="cpp"]srand(time(NULL)); unsigned numberOfAsteroids = (SDL_GetTicks()/30000) + 1; // 1 extra asteroid per 30 seconds if (asteroidsOnScreen < numberOfAsteroids){ if (SDL_GetTicks() - lastTimeTriedToSpamAsteroid > 1000){ // try once per second unsigned chance = rand() % 100; if (chance >= 50){ // 50% chance to spawn an asteroid bool up = rand() % 2; if (up == false){ spawnAsteroid(x = rand()%WIDTH_OF_SCREEN, y = HEIGHT_OF_SCREEN); } else{ spawnAteroidOnLowerPart(x = rand()%WIDTH_OF_SCREEN, y = 0); } } lastTimeTriedToSpamAsteroid = SDL_GetTicks(); } }[/source] EDIT: in this case y = 0 is top part of the screen. [/quote] Thank you, that answer was worth waiting for!
  8. C++ falling asteroids

    The movement part I already have, I'm looking for a solution to making them appear at random times with their number of asteroids onscreen capped from above and below but increasing.
  9. C++ falling asteroids

    Hey guys! I recently started making a game in C++, using SDL. The idea is that you control a guy on the bottom of the screen and asteroids are falling from the sky. Now I'd like to make it so the longer the game goes, the more (and faster) asteroids are and I could really use some help with that. If anyone could show me some pseudo-code on how it's done, I'd be grateful! Thanks in advance!
  10. Python/Pygame networking?

    Hey guys! I'm trying to make a multiplayer game, but networking seems ridiculously hard. I'm looking for some tutorials about multiplayer games and sending objects, using python libaries, but I had no luck in trying to find any helpful ones. Can you point me to the right direction?
  11. Going crazy, collision detection

    Now I must be either a terrible thinker or I just went full crazy but I cannot find out how to solve this one: [CODE] # If there is a collision if (bottom == platformTop) and \ (left >= platformLeft) and \ (right <= platformRight): self.rect.y = platformTop - self.rect.h #if self.falling: # self.vector.y = 0 self.falling = False # ^^^ this doesn't work, you cannot jump from the platform # this is how you fall down from it elif (bottom == platformTop) and \ (left <= platformLeft) or \ (right >= platformRight): self.falling = True [/CODE]
  12. Going crazy, collision detection

    [quote name='Goran Milovanovic' timestamp='1344455632' post='4967502'] The collision model for the "bypassable" platforms should not apply to objects that don't have their feet above the platform. In other words: For all objects below the platform, that platform doesn't exist. So, however you're actually doing your overall collision detection, modify the algorithm to include a special pass for that particular circumstance. [/quote] [quote name='BeerNutts' timestamp='1344455708' post='4967504'] A quick thought is, if you you get a new collision (ie, it wasn't colliding in the last frame), then check the vertical velocity. If it's positive (moving up), ignore the collision. If it's negative (falling), then you need to check where the collision occurs on your player. If it collides at the feet, then you can make the collision stick, and keep the player on top of the platform. If you're player collidies mid-body (or head, etc.), then he's probably moving left to right and falling, and needs to fall through. That is just a quick thought about how I might try it, but i don't have any experience directly with this. Good Luck! EDIT: beat by Goran, but his idea is better than mine, to ensure the feet are above the top of the platform in question. [/quote] Thank you both, solid ideas, I hope I will get it right!
  13. Okay.. So.. What language(s) to learn?

    You could go with Python. If you're also planning to make a website, you can use it for CGI. Pretty sure it's the easiest way.
  14. Hey guys! I posted here yesterday, and it led me to a solution, so I'd like your help again. Now, I'm really going crazy with this, I can't even think properly. My problem is, I'm making a platformer and I'm having a *hard* time getting the collision detection right. What I want is, platforms are bypassable from the bottom and the side, but if you jump through them and your legs are on top of it, they 'become solid'. I spent hours trying, no solution so far. Here is the code: [CODE] # This is a part of the Avatar class, which has a map in self.map which has platforms (their pygame.rect's) in it. for platform in self.map.platforms: left = self.rect.x right = self.rect.x + self.rect.w top = self.rect.y bottom = self.rect.y + self.rect.h platformLeft = platform.rect.x platformRight = platform.rect.x + platform.rect.w platformTop = platform.rect.y platformBottom = platform.rect.y + platform.rect.h # If there is a collision if (bottom >= platformTop) and \ (top <= platformBottom) and \ (right >= platformLeft) and \ (left <= platformRight): pass # NO IDEA [/CODE] Help is very much appreciated, thanks for reading!
  15. Coding jump for a 2d Python game

    [quote name='BeerNutts' timestamp='1344373635' post='4967145'] I would suggest something different from what Shippou suggests. You should test the keys independently, not test if key Up and Key Right. Also, you should be applying a velocity for movement, just just moving the sprite based on keys (which it seems you are doing from looking at the python code). I must admit, it's not the easiest to follow, but, of course, I don't know Python. In another post, i gave some sample code (for C++) which shows, in general how you handle jumping. You should be able to get the gist of it form this code. The main points are: #1, you can jump if you're on the ground and hit the jump key #2, you apply an initial Negative Y velocity(which is up on the screen) once when jumping, and then subtract from the velocity every frame (to simulate gravity). #3, if you hit anything in the Y direction (your head or your feet), reset the location, and set Y velocity to 0. Good Luck! (#define values are just guessed examples, you'll have to change them to fit your game) [code] // Speed player moves left or right #define MOVEMENT_SPEED 10.0f // initial velocity given to player when he jumps #define JUMP_VELOCITY 20.0f void Player::HandleInput() { if (LeftIsPressed()) { this.xVelocity = -MOVEMENT_SPEED; } else if (RightIsPressed()) { this.xVelocity = MOVEMENT_SPEED; else { this.xVelocity = 0.0f; } // Only jump if we're not already jumping or falling if (JumpIsPressed() && this.OnGround) { this.yVelocity = -JUMP_VELOCITY; } } // defines amount to increase downward velocity every frame #define GRAVITY_FORCE 4.0f void Player::Update() { // Apply downward force to player this.yVelocity += GRAVITY_FORCE; // Move the Player this.xLocation += this.xVelocity; this.yLocation += this.yVelocity; // Check we've collide with something above or below us bool CollideBelow; if (CheckCollisionY(CollideBelow)) { // move us back to previous location and Stop Y Velocity this.yLocation -= this.yVelocity; this.yVelocity = 0.0f; if (CollideBelow) { this.OnGround = true; } } else { this.OnGround = false; } // Check if we've collided with anything on our left or right if (CheckCollisionX()) { // move us back to previous location and Stop X Velocity this.xLocation -= this.xVelocity; this.xVelocity = 0.0f; } } [/code] [/quote] Although it was hardly what I was asking for, your post made me feel hopeless so I started rewriting some code that disable me from getting the jumping done. ~1.5 hours later, here I am, having a perfectly functioning jumping and moving system, so thank you!
  • Advertisement