Hot answers tagged platform-games
19
It sounds like what you need is the concept of rooms as opposed to screens. Screens 1-3 would be one room, e.g. Your rooms could then be of any size and shape, or even restricted to the size of multiples of a screen.
Your camera would follow the player through a given room, up until the player gets too close to the border (half a screen width). When the ...
18
When a player collides with a wall while jumping (or, if you like, falling), turn on a flag for the next 100 milliseconds or so that causes an attempt to jump to successfully initiate a jump (ignoring any surface contact checks) with a fair amount of speed on the X axis in the direction away from the wall. Remember to turn the flag off early if a jump is in ...
15
Let's separate your problem into its distinct issues...
A word on code quality
Your code currently has your platforms directly controlling your player's velocity and even the world's gravity constant. It's hacky, and it's procedural when it should be object-oriented. Once you start expanding this game things are going to get ugly fast.
You need to ...
15
I have a personal logic issue on a regular basis that you seem to be expressing here. It's that sometimes you're looking at the logic and programming from the wrong direction entirely. In this case, you seem to not be realizing that from the beginning you know which is happening, because of the logic code. You should already know, programmatically speaking, ...
12
In using the word connectedness, you've come within a hair's breadth of the tool best suited to determining a solution: graph theory.
Connectedness is a property of graphs. Graphs can be either connected or disconnected (as you're experiencing, AKA a multigraph). Any game level, in any number of dimensions, can be represented as a graph, and logically, this ...
8
I would suggest treating this as a pseudo-physics problem and solve it by using ground friction.
You're already using gravity to hold the character on the ground, this handles the situations where platforms move up and down. To handle the left and right movement, the ground should exert a great deal of friction on the character. Typically this friction ...
8
You can do this in C#, but you'll likely need to P/Invoke a lot of the functionality you'd need. C or C++ is probably more well-suited to the task -- you'll have fewer hoops to jump through. There are a few open source "cheat engine" projects out there you can look at for a better idea of what you're going to have to do.
How do I find the correct memory
...
8
What I always do in this case is store a frameTime variable and store the last update time variable inside my animation class. Then I only update the frame if the currentTime - lastUpdateTime > frameTime, in which case I also set last update time to currentTime.
Huzzah for animation =]
7
Isn't it as simple as having a collection of tile locations and frame counters that get updated?
So where you have that code now (in rough pseudocode),
if( thisTile == breakable && !breakingTiles.Contains( thisTile ) )
{
breakingTiles.Add( thisTile );
}
And somewhere else you do something like
foreach( tile in breakingTiles )
{
...
6
If you want a rigid-swing, so the distance to the rotation-point is constant, just treat the character as a point on a circle centered at the rotation point. Give him a one-dimensional (along the circle) angular-velocity. Each frame the angular-acceleration should be accelerationDueToGravity * cos(angleOfPlayerOnCircle) (with 0-degrees pointing right).
If ...
6
Check out this similar question:
Collision Resolution
And also, from http://www.metanetsoftware.com/technique/tutorialA.html#section5 (which you posted a link to :) )
SECTION 5: Fast-Moving Objects
As mentioned above, small and/or fast-moving objects can produce
problems when using a static collision test. There are several
approaches that can ...
6
The point of a quadtree is to efficiently cull large chunks of the data so that you only spend time on the data in the immediate vicinity. However a 2D array already gives you location-specific random access, so for a 2D game that may make a quadtree redundant. In a 3D game you can't use an array to locate everything and that's where quadtrees (or better yet ...
6
As far as 1) you'll need to use a toggle state.
Fire ONLY if the user did not click the previous tick, and is registered as clicking this tick.
This can be thought of as the rising edge of the click state.
here should the fire logic be called
^
clicked ___
not clicked ___|
For 2) it seems that your update() ...
5
Here's the method I found. It might be flawed, but I haven't found any problems with it yet in my cursory analysis. It also works for arbitrary polygons with a few minor modifications.
In the illustrations below, the blue object is moving and the red object is stationary.
Step 1: For each polygon, find the two farthest points along the projection of that ...
5
The physics system neither knows nor cares why the player is moving in a particular direction. It is your game that caused the physics system to move the player that way, and it is therefore the responsibility of your game to keep track of that. The player entity should have some state on it that will tell if it is jumping, climbing, running, etc. You ...
5
You want to modify the player's position, not its source rectangle.
As I understand it, you use playerRect to represent the rectangle inside the image to draw, in order to animate it properly. That is the source rectangle and it does not affect where the player is drawn.
What you want is to modify the player's position field in order to really clamp its ...
5
I would represent Buff/Debuff effects with a single class like this:
public class Buff
{
public BuffType BuffType;
public float Value; //The bonus percentage, for example: -12.5 or 25
}
enum BuffType
{
Speed, FireDamage, ColdDamage, Range //etc.
}
Each and every Tower and Creature instance has a property public List<Buff> CurrentBuffs; ...
4
General approaches to this problem:
Construct the map in a way that guarantees connectedness from the start. Many of the dungeon generators on PCG wiki work this way.
Generate a potentially disconnected map, and then write something (maybe a pathfinder) that checks for connectedness. Throw away the maps that don't work.
Generate a potentially disconnected ...
4
What you are basically talking about is Procedural Content Generation. Roughly, you want to use a randomizing algorithm to make a "map" of upcoming content, and then run a check over that map to look for problems like "This gap is too small and makes the level impossible."
I found, of all things, a wiki dedicated to the topic, which also has some code ...
3
Here is one way to do it.
Set a minimum distance that things can spawn at, so things can always be winnable, but make this distance almost impossible to win.
Have a difficulty variable that that starts out high for easy, and lowers as it gets harder.
Set the position of the next object at the minimum distance + difficulty variable + a small random number.
...
3
I haven't taken their courses, nor am I a professional game developer, so take this as it is. I'll try to keep this concise.
Basically, these courses focus on specifics, like graphics, etc. Like my comment mentions, game dev is a whole bunch of stuff -- how to design a game, polish it, play-test it, etc. etc. and you won't learn that from any course.
I'm a ...
3
I'll give my input since I've used their package before (and no, I'm in no way affiliated with them). You may have noticed that they're currently having a sale where for 99$ you get access to most of their content across a lot of different topics. For instance:
C++ Programming for Game Developers - Module I and II
Graphics Programming with DirectX 9 - ...
3
This is a really common problem, and I'd be very surprised if it hasn't been answered several times already.
Short version of several potential fixes:
1) Ignore internal edges between tiles using flags. For each tile, set a flag for each of its four sides indicating whether that side is external (adjacent to an empty cell) or not. Then only do collision ...
3
Your problem with removing bullets from the list while iterating the list is a common one. It happens in many languages (not just Javascript).
If you want to remove an object from the list while you're iterating it - don't.
Instead, set a flag (I normally use "dead") to say that this object is "dead". Then have some code which checks the "dead" flags ...
3
The keypress issue
Apart from solving it manually which is already brilliantly answered, I recommend the jquery.hotkeys library, as it will also help with other game-related keyboard handling.
The undefined issue
There are at least two issues with the last part, the first is the already noted one by AlexanderBrevig that you're removing bullets in update ...
2
Your puzzles will flow from the mechanics of your game, so you should start by defining those mechanics. For example, can the player run and jump? I would assume yes, since that's pretty much the definition of a platform game, but you should list that concretely.
What other stuff can the player do? For example, can the player collect keys to open doors? Can ...
2
If you're a C++/object-oriented kinda guy, you might find SFML easier to work with. It's very similar to SDL, except that is has an OO interface. It's not as widespread as SDL, but still has quite a large following.
As for tutorials, since you're experienced with C++ you can probably get away with reading tutorials aimed at other engines and languages and ...
2
If you want perfect terrain contact at all times then you need to stop applying Box2D collision response to the player, and apply your own physics rules, because what you describe is not compatible with newtonian physics rules, which are the rules that Box2D follows.
However, you can get pretty close, while still using newtonian physics.
Increase the mass ...
2
after many attempts I went with box2d.
there are generaly two approches to for this simulation or at least I found 2:
one is to use some circle shapes and connect them using distant joints.
and the other one is to rectangles for the chain itself and then attach them using revolute joints
in each senario you have got to have a ancher (which in my case ...
2
There are no special rules for a platformer vs. any other game in this respect. I suggest that you just start making your game. You'll make a lot of mistakes, but hacking the game together while staying conscious of what one can do better is how I learned to create clean, organized code.
Here are some patterns that you should be aware of when making your ...
Only top voted, non community-wiki answers of a minimum length are eligible
