2 * This file is part of NumptyPhysics
3 * Copyright (C) 2008 Tim Edmonds
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 3 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
37 ATTRIB_CLASSBITS
= ATTRIB_TOKEN
| ATTRIB_GOAL
41 class Scene
: private b2ContactListener
45 Scene( bool noWorld
=false );
48 Stroke
* newStroke( const Path
& p
, int colour
, int attributes
);
49 bool deleteStroke( Stroke
*s
);
50 void extendStroke( Stroke
* s
, const Vec2
& pt
);
51 void moveStroke( Stroke
* s
, const Vec2
& origin
);
52 void setNoMass(Stroke
* s
);
53 void setDefaultMass(Stroke
* s
);
55 bool activate( Stroke
*s
);
59 return m_strokes
.size();
62 Array
<Stroke
*>& strokes() {
69 void setPlayerMax(int);
71 void draw( Canvas
& canvas
, const Rect
& area
);
72 void reset( Stroke
* s
=NULL
);
73 Stroke
* strokeAtPoint( const Vec2 pt
, float32 max
);
75 void setGravity( const std::string
& s
);
77 bool load( unsigned char *buf
, int bufsize
);
78 bool load( const std::string
& file
);
79 bool load( std::istream
& in
);
80 void protect( int n
=-1 );
81 bool save( const std::string
& file
);
85 void createJoints( Stroke
*s
);
86 bool parseLine( const std::string
& line
);
88 // b2ContactListener callback when a new contact is detected
89 virtual void Add(const b2ContactPoint
* point
) ;
93 Array
<Stroke
*> m_strokes
;
94 std::string m_title
, m_author
, m_bg
;
96 static Image
*g_bgImage
;
109 Transform( float32 scale
, float32 rotation
, const Vec2
& translation
);
110 void set( float32 scale
, float32 rotation
, const Vec2
& translation
);
112 inline void transform( const Path
& pin
, Path
& pout
) {
115 pout
.rotate( m_rot
);
116 pout
.translate( m_pos
);
119 inline void transform( Vec2
& vec
) {
121 vec
= Vec2( b2Mul( m_rot
, vec
) ) + m_pos
;
124 inline void inverseTransform( Vec2
& vec
) {
126 vec
= Vec2( b2Mul( m_invrot
, vec
-m_pos
) );
137 extern Transform worldToScreen
;
139 extern void configureScreenTransform( int w
, int h
);