Hey there.
I'll try to break it down as best as I can.
Simpler physics systems (
AABB for example) tend to use less system resources and, in a few ways, are less complicated than more full featured alternatives if for no other reason that they can pretty much be done in a single function.
Code: Select all
--We check to see if box1 and box2 are overlapping. If they are, we return true so that we can choose what happens accordingly.
if box1.x >= box2.x and box1.x <= box2.x+box2.width and
box1.y >= box2.y and box1.y <= box2.y + box2.height then
return true
end
Really simple and works great for many kinds of game. When you want objects to bounce around and react in a realistic way, however, it is probably best to go with a more full featured solution, like box2d (which is the engine implemented in LÖVE). It works great and is not necessarily hard but it takes a bit more time to get used than the simple block of code I showed above.
we mean, choosing the most suitable physics/collision-detection system, how to organize the whole project (files, classes, etc) and so on.
Box2D, as explained above. For the organization of the project, I personally like having the following structure inside my game folder:
art/ --further subdivided according in UI, character or what is needed by the game
sound/
libs/ --I use it for external libraries/modules, this way I can keep them separate from things I've developed and avoid clutter
modules/ --Here I put the game modules for my game. I have a module for generating buttons, a timer, etc...
states/ --Different screens/game states go here. Victory screen, defeat screen, credits, start, game, etc...
main.lua
conf.lua
Mine is a bit more complex because of MoonScript but this is essentially it, if I were using vanilla Lua.
We've read and implemented the wiki tutorials but, they feel «simple» comparing to the idea of the game we would like to do, although they are really good for starting.
Try to see the ideas for the simplicity that they have. Breaking scenario, for instance, could easily be done with a tile system. You store a variable in each tile saying how much health it has left. Depending on how damaged a tile is, it changes the image to correspond to the damage. When it takes enough damage, it changes into an empty tile. If you want a more detailed breakage of the scenario, it does get more complex - you could calculate polygons to hide parts of the geometry or some other technique that I don't know. If you google it, you are bound to find more information.
hang from edge
When the character bumps into a wall, you can have the tile she is bumping into check to see if there is a tile above it. If there isn't, it is an edge tile and then you momentarily remove gravity from the character and change to a "holding the ledge" sprite.
After reading about several libraries like ATL, STI, BUMP and looking at some .love examples around the forums, we still don't get the general concept and the other things mentioned above.
Think of libraries as shortcuts to a goal. Suppose you need a timer but don't know how to create one (or you simply don't have the time). You download someone's library and acquire that functionality.
"But if feels to simple".
In a way, it is. But it is a good kind of simple.
For example, this is how I use my timer:
local timer = require "timer"
timerFight = timer.new(99) --I'm starting a new timer, I'm naming it timerFight and setting it to 99 seconds because Street Fighter.
function startFight()
timerFight.start()
allowMovement()
playSound("Fight!")
end
function updateFight(dt)
if timerFight.isZero == true then stopFight() end
end
My advice with libraries: go slow. There is a big temptation to just grab everything that seems useful and tack it on a project. Don't. Try to visualize what you need, when you need it and if you need it. The ones that you do get, take a bit of time to familiarize and learn. For instance, I'll at some point need help with tweening and I know there are at least two great libraries for that - but I'm not gonna install them right now because I'm not at that point yet.
hitting the enemy (physical contact)
Just check the distance between the two characters. If it is less than the reach of the attack, queue the damage resolution functions.
shooting an enemy
Using Box2D for resolving the part of physics, the rest is easier. Simplest way I can think off is just have them added to a table when the player does the action and destroyed when they hit something or get off screen. Ideally, you would reuse the same bullets but one step a time.
Grappling hook
There is likely a better answer by someone more proficient in Box2D but you simply have it spawn and move in an angle.
Set a variable for reach. If it collides with something within that reach, change it's physical properties so that it acts as a fixture.
I hope this helps!