VelocityRaptor
Simple 2D physics simulation for use in video games.
Install / Use
/learn @Mithreindeir/VelocityRaptorREADME
VelocityRaptor
A programming exercise to make a physics engine. The design and math is due mostly to Erin Catto, and his "Fast and Simple Physics using Sequential Impulses" and "Physics for Game Programmers Talk". For Collision Detection, credit to Dyn4J for best Separate Axis Theorem explanation I've seen, http://www.dyn4j.org/2010/01/sat/
It features Collision detection for convex polygons with the Separate Axis Theorum, and it can support concanve shapes, by using ear clipping to turn concave shapes into triangles. Collision's are resolved with impulses. Units are in pixels.
##Projects Using Velocity Raptor
##Velocity Raptor Demo videos
Velocity Raptor Benchmark and Joints
Velocity Raptor concave and composite polyons
##Usage
To create a world:
vrWorld* world = vrWorldInit(vrWorldAlloc());
world->gravity = vrVect(0, 9.81);
To add a body:
vrRigidBody* body = vrBodyInit(vrBodyAlloc());
body->bodyMaterial.mass = 5;
body->bodyMaterial.invMass = 1.0 / body->bodyMaterial.mass;
body->bodyMaterial.momentInertia = vrMomentForBox(10, 10, body->bodyMaterial.mass);
body->bodyMaterial.invMomentInertia = 1.0 / body->bodyMaterial.momentInertia;
body->bodyMaterial.friction = 0.01;
body->bodyMaterial.restitution = 0.2;
vrWorldAddBody(world, body);
To add a box shape:
vrShape* shape = vrShapeInit(vrShapeAlloc());
shape = vrShapePolyInit(shape);
shape->shape = vrPolyBoxInit(shape->shape, x, y, w, h);
vrArrayPush(body->shape, shape);
To add a polygon shape:
vrShape* shape = vrShapeInit(vrShapeAlloc());
shape = vrShapePolyInit(shape);
vrAddVertexToPolyShape(shape->shape, vrVect(0, 0));
vrAddVertexToPolyShape(shape->shape, vrVect(10, 0));
vrAddVertexToPolyShape(shape->shape, vrVect(10, 10));
vrAddVertexToPolyShape(shape->shape, vrVect(0, 10));
vrArrayPush(body->shape, shape);
To add a circle shape:
vrShape* shape = vrShapeInit(vrShapeAlloc());
shape = vrShapeCircleInit(shape);
shape->shape = vrCircleInit(shape->shape);
vrCircleShape* circle = shape->shape;
circle->center = vrVect(0, 0);
circle->radius = 25;
vrArrayPush(body->shape, shape);
Every tick, call this to update the world:
vrWorldStep(world);
To clean up, and free all memory:
vrWorldDestroy(world);
To remove a body from the world and free its memory before destruction of world
vrWorldRemoveBody(world, body);
Related Skills
qqbot-channel
349.9kQQ 频道管理技能。查询频道列表、子频道、成员、发帖、公告、日程等操作。使用 qqbot_channel_api 工具代理 QQ 开放平台 HTTP 接口,自动处理 Token 鉴权。当用户需要查看频道、管理子频道、查询成员、发布帖子/公告/日程时使用。
docs-writer
100.4k`docs-writer` skill instructions As an expert technical writer and editor for the Gemini CLI project, you produce accurate, clear, and consistent documentation. When asked to write, edit, or revie
model-usage
349.9kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
Design
Campus Second-Hand Trading Platform \- General Design Document (v5.0 \- React Architecture \- Complete Final Version)1\. System Overall Design 1.1. Project Overview This project aims t
