Comments (8)
Vehicles can pose a new problem. Right now there are no entities that are bigger than a single tile, although barely (players are 2 pixels narrower/shorter than the tiles, i.e. 1px leeway on all 4 sides). Small vehicles are definitely easy, but vehicles bigger than a single tile will require changes in the collision logic.
This is because currently, collisions are checked (GetItemOnTileInCollision
) by looking for all entities in the current tile as well as surrounding tiles. This is so that items on adjacent tiles can still collide with each other. With entities larger than a single tile, We'd need to check around the current tile in a range that is at least one row/column larger than the size of the largest entity.
Same goes for rendering too; if things can collide they also need to be drawn in the right Z order. Now we'd need to sort rendering not just based on items in the current tile, but in a perimeter.
from cdogs-sdl.
There's a related issue: go to a proper spacial partitioning system (quadtree etc). That's a lot of work and the benefit is unclear.
from cdogs-sdl.
Instead of increasing the search perimeter, one alternative is to use "pseudo references" that indicate the presence, but not the location of an entity inside a tile. This idea may make collision detection faster as well.
Tiles currently have a collection of references to entities that are in that tile. This is a one-to-one relationship; entities can only exist in one tile at a time. This complicates collision detection a bit though, because entities at tile boundaries can collide with entities in the neighbouring tile, so the collision search is done on all 8 surrounding tiles as well. This works as long as no entities exceed one tile in size.
Instead, in addition to the regular references, we store "pseudo references" as well, and as long as an entity overlaps a tile, it also has a pseudo reference in that tile.
- This makes collision easier, as one simply checks the current tile for references and pseudo references
- It can handle entities larger than one tile, as those entities will simply have pseudo references in every tile it overlaps
- Drawing/Z order is still based on regular references
There are some caveats though:
- Checking for collision for a single entity may require searches in multiple tiles anyway, as that entity may exist in multiple tiles. In this case, duplicate detection needs to be done as well
- Moving entities becomes a bit harder as the multiple pseudo references need to be updated
from cdogs-sdl.
C-Dogs is an 8-directional shooter, which is about movement as much as shooting. The 8-directions creates significant blind spots, which is compensated by moving around a lot.
Turrets (and vehicles to a lesser extent) worsens this limitation, so to compensate we can:
- Use auto-aim #264
- Moving/rotating crosshair (which would require laser sight #267)
- Allow analog movement #272
from cdogs-sdl.
Turrets could be implemented like this, for maximal flexibility:
- bullets optionally can place static map objects instead of doing damage
- static map objects optionally can fire weapons, with an optional auto-aim tag and ammo limit
You could maybe even implement a half-life style health dispenser this way, if you set the bullet damage to -1.
from cdogs-sdl.
And, if you at the same time allow bullets to be static map objecs, you could implement shooting drones.
from cdogs-sdl.
This feature should probably be split as we built it out in parts. Initially we could build it on top of the custom gun system. E.g.
MG emplacement
- Makes you immobile (speed = 0)
- Drops when you switch away from it; doesn't stay in your inventory
- Fixed muzzle position (have a map object as its parent?)
Turret emplacement
In addition to the above:
- Can "enter" the turret (hide player, disable collisions)
- Destructible (map object parent is destructible; need to eject player on destruction)
Jetpack
- Does not change player's gun; they can fire the gun they were holding when they "entered" the vehicle
- Change player physics (more speed, inertia)
- Disable sliding (or custom action when pressing move + switch?)
Hoverbike
In addition to the Jetpack:
- Destructible (movable map objects?)
- Mass (can be knocked back, knocks back actors on collision)
Motorbike
- Basic vehicle physics: has a heading, accelerates while moving towards heading, decelerates and turns while moving to a different heading, brakes while moving opposite to the heading. Need to add the following properties:
- heading
- vehicle rotation (directional sprites for map objects?)
- deceleration
- braking
- acceleration angle threshold
- braking angle threshold
...
from cdogs-sdl.
Went with a different design - vehicles are a special type of actor, and added two references to actors: pilot and vehicle
For the pilot, it controls the vehicle instead of itself, doesn't get drawn and doesn't react to collisions - instead it always follows the vehicle
For the vehicle, it doesn't control itself, and when drawn, will draw the pilot's head instead (if being piloted)
Having vehicles act as actors means minimal changes to other parts of the code.
from cdogs-sdl.
Related Issues (20)
- Changing weapons while standing still HOT 1
- Bombs slot resetting
- Proximity mines over character after placement
- Friendly fire on Distress call from scientific outpost HOT 1
- Wrong mission title
- Poison
- Wrong menu loading
- Impossible to close some menus
- Typos HOT 2
- Multiple map objects per destroy objective HOT 1
- Add correct aspect ratio option
- Petrify Gun
- Check for shared ENet if USE_SHARED_ENET is set HOT 5
- Shift to another hasmap implementation from the deprecated `c_hashmap` HOT 2
- Wrong blood animation HOT 3
- Original Release Campaign? HOT 7
- CVE-apply:In Nanopb before versions 0.3.9.8 and 0.4.5, decoding a specifically formed message can cause invalid `free()` or `realloc()` calls if the message type contains an `oneof` field, and the `oneof` directly contains both a pointer field and a non-pointer field. HOT 1
- Arch Linux x86_64: Segfault on startup HOT 7
- Zig development HOT 2
- Assets revamp
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cdogs-sdl.