Created
July 10, 2019 20:54
-
-
Save jefftime/e2adaa9ca561f90d4805c1b912cb4d43 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Entity { | |
uint32_t id; | |
}; | |
struct Position { | |
float x; | |
float y; | |
}; | |
struct Physics { | |
vector3 velocity; | |
}; | |
struct EntityPosition { | |
uint32_t entity_id; | |
Position pos; | |
} | |
struct EntityPhysics { | |
uint32_t entity_id; | |
Physics phys; | |
}; | |
List<Entity> entities; | |
List<EntityPosition> entity_positions; | |
List<EntityPhysis> entity_physics; | |
void physics_system() { | |
for (entity_phys_info : entity_physics) { | |
// Get related information (position information) | |
entity_pos_info = entity_positions.find(entity_phys_info.entity_id); | |
// Physics time | |
Position old_pos = entity_pos_info.pos; | |
new_pos = physics_calculations(old_pos, entity_phys_info.velocity); | |
// Set changes | |
entity_pos_info.pos = new_pos; | |
} | |
} | |
void main() { | |
// Main loop | |
for (;;) { | |
physics_system(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment