Skip to content

Commit 359fecf

Browse files
author
RandyGaul
committed
Initial commit
0 parents  commit 359fecf

25 files changed

+2653
-0
lines changed

.gitattributes

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto
3+
4+
# Custom for Visual Studio
5+
*.cs diff=csharp
6+
*.sln merge=union
7+
*.csproj merge=union
8+
*.vbproj merge=union
9+
*.fsproj merge=union
10+
*.dbproj merge=union
11+
12+
# Standard to msysgit
13+
*.doc diff=astextplain
14+
*.DOC diff=astextplain
15+
*.docx diff=astextplain
16+
*.DOCX diff=astextplain
17+
*.dot diff=astextplain
18+
*.DOT diff=astextplain
19+
*.pdf diff=astextplain
20+
*.PDF diff=astextplain
21+
*.rtf diff=astextplain
22+
*.RTF diff=astextplain

.gitignore

+163
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
#################
2+
## Eclipse
3+
#################
4+
5+
*.pydevproject
6+
.project
7+
.metadata
8+
bin/
9+
tmp/
10+
*.tmp
11+
*.bak
12+
*.swp
13+
*~.nib
14+
local.properties
15+
.classpath
16+
.settings/
17+
.loadpath
18+
19+
# External tool builders
20+
.externalToolBuilders/
21+
22+
# Locally stored "Eclipse launch configurations"
23+
*.launch
24+
25+
# CDT-specific
26+
.cproject
27+
28+
# PDT-specific
29+
.buildpath
30+
31+
32+
#################
33+
## Visual Studio
34+
#################
35+
36+
## Ignore Visual Studio temporary files, build results, and
37+
## files generated by popular Visual Studio add-ons.
38+
39+
# User-specific files
40+
*.suo
41+
*.user
42+
*.sln.docstates
43+
44+
# Build results
45+
[Dd]ebug/
46+
[Rr]elease/
47+
*_i.c
48+
*_p.c
49+
*.ilk
50+
*.meta
51+
*.obj
52+
*.pch
53+
*.pdb
54+
*.pgc
55+
*.pgd
56+
*.rsp
57+
*.sbr
58+
*.tlb
59+
*.tli
60+
*.tlh
61+
*.tmp
62+
*.vspscc
63+
.builds
64+
*.dotCover
65+
66+
## TODO: If you have NuGet Package Restore enabled, uncomment this
67+
#packages/
68+
69+
# Visual C++ cache files
70+
ipch/
71+
*.aps
72+
*.ncb
73+
*.opensdf
74+
*.sdf
75+
76+
# Visual Studio profiler
77+
*.psess
78+
*.vsp
79+
80+
# ReSharper is a .NET coding add-in
81+
_ReSharper*
82+
83+
# Installshield output folder
84+
[Ee]xpress
85+
86+
# DocProject is a documentation generator add-in
87+
DocProject/buildhelp/
88+
DocProject/Help/*.HxT
89+
DocProject/Help/*.HxC
90+
DocProject/Help/*.hhc
91+
DocProject/Help/*.hhk
92+
DocProject/Help/*.hhp
93+
DocProject/Help/Html2
94+
DocProject/Help/html
95+
96+
# Click-Once directory
97+
publish
98+
99+
# Others
100+
[Bb]in
101+
[Oo]bj
102+
sql
103+
TestResults
104+
*.Cache
105+
ClientBin
106+
stylecop.*
107+
~$*
108+
*.dbmdl
109+
Generated_Code #added for RIA/Silverlight projects
110+
111+
# Backup & report files from converting an old project file to a newer
112+
# Visual Studio version. Backup files are not needed, because we have git ;-)
113+
_UpgradeReport_Files/
114+
Backup*/
115+
UpgradeLog*.XML
116+
117+
118+
119+
############
120+
## Windows
121+
############
122+
123+
# Windows image file caches
124+
Thumbs.db
125+
126+
# Folder config file
127+
Desktop.ini
128+
129+
130+
#############
131+
## Python
132+
#############
133+
134+
*.py[co]
135+
136+
# Packages
137+
*.egg
138+
*.egg-info
139+
dist
140+
build
141+
eggs
142+
parts
143+
bin
144+
var
145+
sdist
146+
develop-eggs
147+
.installed.cfg
148+
149+
# Installer logs
150+
pip-log.txt
151+
152+
# Unit test / coverage reports
153+
.coverage
154+
.tox
155+
156+
#Translations
157+
*.mo
158+
159+
#Mr Developer
160+
.mr.developer.cfg
161+
162+
# Mac crap
163+
.DS_Store

Body.cpp

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include "Precompiled.h"
2+
3+
Body::Body( Shape *shape_, uint32 x, uint32 y )
4+
: shape( shape_->Clone( ) )
5+
{
6+
shape->body = this;
7+
position.Set( (real)x, (real)y );
8+
velocity.Set( 0, 0 );
9+
angularVelocity = 0;
10+
torque = 0;
11+
orient = Random( -PI, PI );
12+
force.Set( 0, 0 );
13+
staticFriction = 0.5f;
14+
dynamicFriction = 0.3f;
15+
restitution = 0.2f;
16+
shape->Initialize( );
17+
r = Random( 0.2f, 1.0f );
18+
g = Random( 0.2f, 1.0f );
19+
b = Random( 0.2f, 1.0f );
20+
}
21+
22+
void Body::SetOrient( real radians )
23+
{
24+
orient = radians;
25+
shape->SetOrient( radians );
26+
}

Body.h

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#ifndef BODY_H
2+
#define BODY_H
3+
4+
struct Shape;
5+
6+
struct Body
7+
{
8+
Body( Shape *shape_, uint32 x, uint32 y );
9+
10+
void ApplyForce( const Vec2& f )
11+
{
12+
force += f;
13+
}
14+
15+
void ApplyImpulse( const Vec2& impulse, const Vec2& contactVector )
16+
{
17+
velocity += im * impulse;
18+
angularVelocity += iI * Cross( contactVector, impulse );
19+
}
20+
21+
void SetStatic( void )
22+
{
23+
I = 0.0f;
24+
iI = 0.0f;
25+
m = 0.0f;
26+
im = 0.0f;
27+
}
28+
29+
void SetOrient( real radians );
30+
31+
Vec2 position;
32+
Vec2 velocity;
33+
34+
real angularVelocity;
35+
real torque;
36+
real orient; // radians
37+
38+
Vec2 force;
39+
Vec2 oldForce;
40+
41+
// Set by shape
42+
real I; // moment of inertia
43+
real iI; // inverse inertia
44+
real m; // mass
45+
real im; // inverse masee
46+
47+
real staticFriction;
48+
real dynamicFriction;
49+
real restitution;
50+
51+
Shape *shape;
52+
53+
real r, g, b;
54+
};
55+
56+
#endif // BODY_H

Clock.cpp

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
2+
#include "Precompiled.h"
3+
4+
Clock::Clock( )
5+
{
6+
// Assign to a single processor
7+
SetThreadAffinityMask( GetCurrentThread( ), 1 );
8+
9+
// Grab frequency of this processor
10+
QueryPerformanceFrequency( &m_freq );
11+
12+
// Setup initial times
13+
Start( );
14+
Stop( );
15+
}
16+
17+
Clock::~Clock( )
18+
{
19+
}
20+
21+
// Records current time in start variable
22+
void Clock::Start( void )
23+
{
24+
QueryPerformanceCounter( &m_start );
25+
}
26+
27+
// Records current time in stop variable
28+
void Clock::Stop( void )
29+
{
30+
QueryPerformanceCounter( &m_stop );
31+
}
32+
33+
// Get current time from previous Start call
34+
f32 Clock::Elapsed( void )
35+
{
36+
QueryPerformanceCounter( &m_current );
37+
return (m_current.QuadPart - m_start.QuadPart) / (float)m_freq.QuadPart;
38+
}
39+
40+
// Time between last Start and Stop calls
41+
f32 Clock::Difference( void )
42+
{
43+
return (m_stop.QuadPart - m_start.QuadPart) / (float)m_freq.QuadPart;
44+
}
45+
46+
// Get the current clock count
47+
LONGLONG Clock::Current( void )
48+
{
49+
QueryPerformanceCounter( &m_current );
50+
return m_current.QuadPart;
51+
}
52+
53+
void Clock::Query( LARGE_INTEGER& query )
54+
{
55+
QueryPerformanceCounter( &query );
56+
}

Clock.h

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
class Clock
2+
{
3+
public:
4+
Clock( );
5+
~Clock( );
6+
7+
// Records current time in start variable
8+
void Start( void );
9+
10+
// Records current time in stop variable
11+
void Stop( void );
12+
13+
// Time since last Start call
14+
f32 Elapsed( void );
15+
16+
// Time between last Start and Stop calls
17+
f32 Difference( void );
18+
19+
// Get the current clock count
20+
LONGLONG Current( void );
21+
22+
private:
23+
LARGE_INTEGER m_freq;
24+
LARGE_INTEGER m_start, m_stop, m_current;
25+
26+
friend class Timer;
27+
// Callbacks for Timer
28+
void Query( LARGE_INTEGER& query );
29+
};

0 commit comments

Comments
 (0)