theCheeseGrater on DeviantArthttps://www.deviantart.com/thecheesegrater/art/SAGE-v0-1-103370590theCheeseGrater

Deviation Actions

theCheeseGrater's avatar

SAGE v0.1

Published:
381 Views

Description

A semi-complete physics engine which uses SAT (Separating Axis Theorem) Collisions.

see: [link] [which is an awesome article for anyone interested in game math/geometry etc]

If i can figure out a way to find out an approximate location where a collision occurs, i will be able to add torque effects to the collisions... which would be really cool and make me happy :). But the SAT method is difficult to adapt in this way.

here is the timeline code:



// Import My "Simple, Acronymed, Game Engine"
import SAGE.*;
stage.quality="LOW"
x=400,y=300;
var polys:Array = new Array()
var i:uint;
var p:SPoly;
for(i=0;i<14;i++){
p = new SPoly()
p.addVert(new SVect(-10,-10));
p.addVert(new SVect(10,-10));
p.addVert(new SVect(10,10));
p.addVert(new SVect(-10,10));
p.endVert();
p.rotation = Math.random()*ANG.PI2;
p.scale = Math.random()*2+0.5
p.x=Math.random()*500-250;
p.y=Math.random()*500-250;
polys.push(p);
}
addEventListener("enterFrame",EnterFrame);
function EnterFrame(e){
// Update:
for(i=0;i< polys.length;i++){
polys[i].rotation+=0.05+i/90
polys[i].x+= (mouseX-polys[i].x)/30
polys[i].y+= (mouseY-polys[i].y)/30
}
SHit.collideArray(polys);
//SHit.collideArray(polys); // 2nd Pass
// Draw:
graphics.clear();
SDraw.drawArray(polys,graphics);
}
Image size
800x600px 3.76 KB
© 2008 - 2024 theCheeseGrater
Comments0
Join the community to add your comment. Already a deviant? Log In