Bottle 2D - Lua API 1.0.0
All you need to create games using bottle2D.

header.hpp

Go to the documentation of this file.
00001 
00002 
00004 class Vector2D
00005 {
00006 public:
00007      Vector2D(number x, number y);
00008      Vector2D();
00009     Vector2D  operator+( Vector2D vect);
00010     Vector2D  operator-( Vector2D vect);
00011     bool  operator==( Vector2D vect);
00012     Vector2D  operator*(number nb);
00013     Vector2D  operator/(number nb);
00014     float x;
00015     float y;
00016 };
00017 
00019 class Color
00020 {
00021 public:
00022      Color();
00023      Color(number r, number g, number b);
00024      Color(number r, number g, number b, number a);
00025     char r;
00026     char g;
00027     char b;
00028     char a;
00029 };
00030 
00032 class Texture
00033 {
00034 public:
00036      Texture();
00038     number GetWidth();
00040     number GetHeight();
00042     Vector2D GetSize();
00044     nil LoadFromFile( string Filename);
00045 };
00046 
00048 class Sound
00049 {
00050 public:
00052      Sound();
00054     nil LoadFromFile( string Filename);
00055 };
00056 
00058 class Music
00059 {
00060 public:
00062      Music();
00068     nil LoadFromFile( string Filename);
00072     number GetDuration();
00076     number GetChannelsCount();
00079     nil Play();
00082     nil Pause();
00085     nil Stop();
00090     nil SetLoop(bool Loop);
00095     nil SetPitch(number Pitch);
00100     nil SetVolume(number Volume);
00101 //  */
00105     bool GetLoop();
00109     number GetPitch();
00113     number GetVolume();
00117     number GetPlayingOffset();
00121     bool IsPlaying();
00122 };
00123 
00125 class Font
00126 {
00127 public:
00129      Font();
00131     nil LoadFromFile( string Filename);
00132 };
00133 
00134 
00136 class Arguments
00137 {
00138 public:
00140     number GetCount();
00142     string GetNext();
00144     nil Add( string arg);
00146     nil Clear();
00147 };
00148 
00150 class ModeInfo
00151 {
00152 public:
00153     string fullName;
00154     string idName;
00155     string auther;
00156     string path;
00157     string description;
00158     string version;
00159     string screenshot;
00160 };
00161 
00163 class ConfigNode
00164 {
00165 public:
00167     string GetString( string key);
00169     number GetNumber( string key);
00171     bool ChildExists( string key);
00173     nil SetValue( string key,  string value);
00175     nil SetValue( string key, number value);
00177     ConfigNode AccessNode( string key);
00179     nil Remove( string key);
00181     nil Clear();
00182 };
00183 
00185 class ConfigManager
00186 {
00187 public:
00189     ModeInfo GetModeInfo( string idName);
00191     ModeInfo GetModeInfo(number id);
00193     string GetCurrentModeId();
00195     ConfigNode GetRootConfigNode();
00197     number GetModeCount();
00199     ConfigNode GetGlobalConfigNode();
00201     nil InitLocales( string path);
00202 };
00203 
00204 
00206 class EventHandlerBase
00207 {
00208 public:
00209     nil Destroy();
00210     bool ShouldBeDestroyed();
00212     nil SetUserData( string id,  luaObject data);
00214     luaObject GetUserData( string id);
00216     bool UserDataExists( string id);
00217 };
00218 
00219 
00221 class Timer : public EventHandlerBase
00222 {
00223 public:
00225     float interval;
00227     number GetInterval();
00229     nil SetInterval(number numbererval);
00231     nil Start();
00233     nil Stop();
00235     bool IsRunning();
00236 };
00237 
00239 class Chronometer : public EventHandlerBase
00240 {
00241 public:
00243     float totalTime;
00245     number GetTotalTime();
00247     nil SetTotalTime(number totalTime);
00249     float ratio;
00251     number GetRatio();
00253     nil SetRatio(number newRatio);
00255     nil Restart();
00257     nil Start();
00259     nil Stop();
00261     bool IsRunning();
00262 };
00263 
00265 class MouseZoneEvent : public EventHandlerBase
00266 {
00267 public:
00269     float zone;
00271     PhysicObject GetZone();
00273     nil SetZone(PhysicObject zone);
00275     bool IsInside();
00276 };
00277 
00278 
00280 class Object
00281 {
00282 public:
00283     bool  operator==( Object obj);
00285     Vector2D position;
00287     Vector2D GetPosition();
00289     nil SetPosition( Vector2D pos);
00291     float rotation;
00293     number GetRotation();
00295     nil SetRotation(number angle);
00297     float x;
00299     float y;
00301     number GetPositionX();
00303     number GetPositionY();
00305     nil SetPositionX(number pos);
00307     nil SetPositionY(number pos);
00309     Vector2D globalPosition;
00311     Vector2D GetGlobalPosition();
00313     nil SetGlobalPosition( Vector2D pos);
00315     Vector2D rotation;
00317     number GetGlobalRotation();
00319     nil SetGlobalRotation(number rotation);
00321     nil Rotate(number angle);
00323     nil Move( Vector2D mvt);
00325     std::string name;
00327     string GetName();
00329     nil SetName( string str);
00331     float speed;
00333     nil SetSpeed( Vector2D speed);
00335     Vector2D GetSpeed();
00337     float angularVelocity;
00339     nil SetAngularVelocity(number speed);
00341     number GetAngularVelocity();
00343     number GetType();
00345     long GetUniqueId();
00347     nil ChangeParent(Group parent);
00349     nil Destroy();
00351     Group GetParent();
00353     Object Clone();
00354     Object CloneToGroup(Group newParent);
00356     nil SetUserData( string id,  luaObject data);
00358     luaObject GetUserData( string id);
00360     bool UserDataExists( string id);
00362     PhLine CastIntoPhLine();
00364     PhRect CastIntoPhRect();
00366     PhTriangle CastIntoPhTriangle();
00368     PhCircle CastIntoPhCircle();
00370     PhShape CastIntoPhShape();
00372     Group CastIntoGroup();
00374     ParticleSource CastIntoParticleSource();
00376     Shape CastIntoShape();
00378     Sprite CastIntoSprite();
00380     Text CastIntoText();
00382     PostFX CastIntoPostFX();
00384     Screen CastIntoScreen();
00386     ScreenRenderer CastIntoScreenRenderer();
00388     Screen GetParentScreen();
00389 };
00390 
00391 
00393 class Drawable : public Object
00394 {
00395 public:
00397     int zPos;
00399     number GetZpos();
00401     nil SetZpos(number val);
00403     number GetLowZPos();
00405     bool visible;
00407     nil Show(bool visible = true);
00409     nil Hide();
00411     bool IsVisible();
00413     bool IsUpperThan( Drawable drawableToCompare);
00414 };
00415 
00416 
00418 class PhysicObject : public Object
00419 {
00420 public:
00422     bool IsPointInside( Vector2D ponumber);
00424     std::string eventFunction;
00428     nil SetEventFunction( luaObject luaFunction);
00430     luaObject GetEventFunction();
00432     number GetPhysicGroup();
00433 };
00434 
00435 
00440 class Group : public Drawable
00441 {
00442 public:
00444     Group Clone();
00446     Group CloneToGroup(Group newParent);
00448     Vector2D scale;
00450     nil SetScale( Vector2D scale);
00452     Vector2D GetScale();
00454     number GetChildCount();
00456     PhysicObject GetPhysicChild(number id);
00458     number GetPhysicChildCount();
00460     Drawable GetDrawableChild(number id);
00462     number GetDrawableChildCount();
00464     nil DestroyChildren();
00466     nil EnableCut(bool isCut);
00468     bool IsCut();
00470     nil SetCutRect( Vector2D position,  Vector2D size);
00472     Vector2D GetCutRectPosition();
00474     Vector2D GetCutRectSize();
00475 /*#define X(typeName, typeId)             typeName *FindByName ## typeName(const std::string &name);
00476 X_OBJ_LIST
00477 #undef X*/
00481     luaObject GetChildTable();
00486     luaObject FindByIndex(number id);
00488     luaObject FindByName( string name);
00490     PhLine FindByNamePhLine( string name);
00492     PhRect FindByNamePhRect( string name);
00494     PhTriangle FindByNamePhTriangle( string name);
00496     PhCircle FindByNamePhCircle( string name);
00498     PhShape FindByNamePhShape( string name);
00500     Group FindByNameGroup( string name);
00502     ParticleSource FindByNameParticleSource( string name);
00504     Shape FindByNameShape( string name);
00506     Sprite FindByNameSprite( string name);
00508     Text FindByNameText( string name);
00510     PostFX FindByNamePostFX( string name);
00512     Screen FindByNameScreen( string name);
00514     ScreenRenderer FindByNameScreenRenderer( string name);
00522     PhLine CreatePhLine(number phGroupId,  string name,  Vector2D pt1,  Vector2D pt2);
00529     PhRect CreatePhRect(number phGroupId,  string name,  Vector2D size);
00538     PhTriangle CreatePhTriangle(number phGroupId,  string name,  Vector2D pt1,  Vector2D pt2,  Vector2D pt3);
00545     PhShape CreatePhShape(number phGroupId,  string name);
00553     PhCircle CreatePhCircle(number phGroupId,  string name,  Vector2D center, number radius);
00558     Group CreateGroup( string name);
00569     ParticleSource CreateParticleSource( string name,  ParticleModel model, number maxParticleNumber);
00574     Shape CreateShape( string name);
00585     Shape CreateShapeLine( string name,  Vector2D P1,  Vector2D P2, number Thickness,  Color Col, number Outline,  Color OutlineCol);
00595     Shape CreateShapeRectangle( string name,  Vector2D P1,  Vector2D P2,  Color Col, number Outline,  Color OutlineCol);
00605     Shape CreateShapeCircle( string name,  Vector2D Center, number Radius,  Color Col, number Outline,  Color OutlineCol);
00610     Sprite CreateSprite( string name);
00616     Text CreateText( string name,  string text);
00621     PostFX CreatePostFX( string name);
00626     ScreenRenderer CreateScreenRenderer( string name);
00627     nil RegisterEventAutoRemoveOnDestroy(EventHandlerBase event);
00633 };
00634 
00635 
00637 class ScreenConfig
00638 {
00639 public:
00641      ScreenConfig();
00643      ScreenConfig( Vector2D size);
00645     nil ChangeSize( Vector2D size);
00647     nil CameraReset();
00649     float forcedRatio;
00651     nil SetForcedRatio(number value);
00653     number GetForcedRatio();
00655     bool isFixedRatio;
00657     nil SetFixedRatio(bool value);
00659     bool IsFixedRatio();
00661     Vector2D screenSize;
00663     nil SetScreenSize( Vector2D value);
00665     Vector2D GetScreenSize();
00667     Vector2D cameraTopLeft;
00669     nil SetCameraTopLeft( Vector2D value);
00671     Vector2D GetCameraTopLeft();
00673     Vector2D cameraBottomRight;
00675     nil SetCameraBottomRight( Vector2D value);
00677     Vector2D GetCameraBottomRight();
00679     nil CameraMove( Vector2D mvt);
00681     nil CameraZoom(number addedZoom);
00683     nil CameraZoom(Vector2D addedZoom);
00684 // /** Access the camera zoom */
00686     nil CameraSetZoom(number zoom);
00688     nil CameraSetZoom(Vector2D zoom);
00689 // /** Get zoom, using screen size */
00691     Vector2D cameraCenter;
00693     nil CameraSetCenter( Vector2D center);
00695     Vector2D CameraGetCenter();
00697     Vector2D cameraHalfSize;
00699     nil CameraSetHalfSize( Vector2D halfSize);
00701     Vector2D CameraGetHalfSize();
00702 };
00703 
00709 class Screen : public Group
00710 {
00711 public:
00719     EventHandlerBase RegisterButtonEvent( luaObject luaFunction,  string keyName, bool pressed);
00727     EventHandlerBase RegisterButtonInZoneEvent( luaObject luaFunction, MouseZoneEvent zoneEvt,  string keyName, bool pressed);
00733     EventHandlerBase RegisterMouseMoveEvent( luaObject luaFunction);
00739     Timer RegisterTimer( luaObject luaFunction, number numbererval, bool isRunning = true);
00745     Chronometer RegisterChronometer( luaObject luaFunction, number totalTime, bool isRunning = true);
00751     MouseZoneEvent RegisterMouseZoneEvent( luaObject luaFunction, PhysicObject zone);
00755     EventHandlerBase RegisterFrameEvent( luaObject luaFunction);
00757     nil PlaySound(Sound sound);
00759     nil SetMouseRelative(bool relative);
00761     bool IsMouseRelative();
00763     nil ShowCursor(bool show);
00765     bool IsCursorVisible();
00767     number GetEventCount();
00768 // /** Show the FPS (for optimisation) */
00769 // /** Tels if FPS ate shown */
00771     float timeSpeed;
00773     nil SetTimeSpeed(number timeSpeed);
00775     number GetTimeSpeed();
00782     nil AddPhysicGroup(number phGroupId1, number phGroupId2);
00784     Color backgroundColor;
00786     Color GetBackgroundColor();
00788     nil SetBackgroundColor( Color color);
00790     ScreenConfig screenConfig;
00792     ScreenConfig GetScreenConfig();
00794     nil SetScreenConfig( ScreenConfig screenConfig);
00795 };
00796 
00797 
00802     nil ChangeScreen( string name);
00804     nil ChangeScreen(Screen screen);
00806     Screen CreateScreen( string name);
00808     Screen CreateScreen( string name,  ScreenConfig screenConfig);
00810     string GetCommonDataPath();
00812     string GetModePath();
00817     string GetEngineVersion();
00819     nil RequestRecreateRenderWindow();
00823     number GetFrameTime();
00825     nil Quit();
00829     number ConvertRatioCosAccelerationDeceleration(number ratio);
00834     number ConvertRatioAcceleration(number ratio, number coefficient);
00839     number ConvertRatioDeceleration(number ratio, number coefficient);
00841     Vector2D GetMousePosition();
00843     ConfigNode GetModeConf();
00845     ModeInfo GetModeInfo();
00847     nil LoadMode( string idName);
00849     ConfigManager GetConfigManager();
00851     nil ForceFrame();
00853     nil ShowConsole(bool isVisible);
00855     bool IsConsoleVisible();
00857     bool IsKeyPressed( string keyName);
00861     Vector2D GetRealWindowSize();
00863     nil SetShowPhysicObjects(bool isVisible);
00865     bool IsShowPhysicObjects();
00867     string _( string str);
00869     string GetTypeName(number typeId);
00871     string GetChildTree();
00875     luaObject GetAvaibleVideoModes();
00877     luaObject GetCmdArguments();
00878 
00879 
00880 
00881 
00883 class ParticleModel
00884 {
00885 public:
00887      ParticleModel();
00889      ParticleModel(number lifeTimeMin, number lifeTimeMax);
00893     nil AddFixedParam( string name, number value);
00897     nil AddMutableParam( string name, number begin, number end);
00901     nil AddRandomParam( string name, number min, number max);
00905     nil AddMutableRandomParam( string name, number begin_min, number begin_max, number end_min, number end_max);
00907     nil SetLifeTime(number min, number max);
00908 };
00909 
00911 class ParticleEmitter
00912 {
00913 public:
00915      ParticleEmitter();
00917     nil SetAngles(number angleA, number angleB);
00919     nil SetDirection( Vector2D direction);
00921     nil MakeLine( Vector2D pt1,  Vector2D pt2);
00923     nil MakeDisk( Vector2D center, number radius);
00925     nil MakeCircle( Vector2D center, number radius);
00927     nil MakePoint( Vector2D position);
00928 };
00929 
00933 class ParticleSource : public Drawable
00934 {
00935 public:
00937     ParticleSource Clone();
00939     ParticleSource CloneToGroup(Group newParent);
00941     int flow;
00946     nil SetFlow(number flow);
00948     number GetFlow();
00950     int tank;
00955     nil SetTank(number tank);
00957     number GetTank();
00959     Vector2D gravity;
00961     nil SetGravity( Vector2D force);
00963     Vector2D GetGravity();
00965     float friction;
00967     nil SetFriction(number friction);
00969     number GetFriction();
00971     nil SetForce(number min, number max);
00973     float minForce;
00975     number GetMinForce();
00977     nil SetMinForce(number minForce);
00979     float maxForce;
00981     number GetMaxForce();
00983     nil SetMaxForce(number maxForce);
00985     nil SetEmitterAngle(number angle);
00987     number GetEmitterAngle();
00989     nil SetEmitterDirection( Vector2D direction);
00991     Vector2D GetEmitterDirection();
00993     nil SetEmitter( ParticleEmitter emitter);
00995     nil MakeRenderLines(number length, number width);
00997     nil MakeRenderPoints(number ponumberSize);
00999     nil MakeRenderImages(Texture img,  Vector2D size, bool blendAdd);
01001     bool autoDestroy;
01003     nil SetAutoDestroy(bool autoDestroy);
01005     bool IsAutoDestroy();
01009     nil ComputeParticles(number time);
01011     luabind::object onTankEmptyEventFunction;
01015     nil SetOnTankEmptyEventFunction( luaObject luaFunction);
01017     luaObject GetOnTankEmptyEventFunction();
01018 };
01019 
01020 
01022 class PhCircle : public PhysicObject
01023 {
01024 public:
01026     float radius;
01028     nil SetRadius(number radius);
01030     number GetRadius();
01032     PhCircle Clone();
01034     PhCircle CloneToGroup(Group newParent);
01035 };
01036 
01037 
01039 class PhLine : public PhysicObject
01040 {
01041 public:
01043     sf::Vecor2f vector;
01045     nil SetVector( Vector2D vector);
01047     Vector2D GetVector();
01049     sf::Vecor2f pt2;
01051     nil SetPt2( Vector2D pt2);
01053     Vector2D GetPt2();
01055     PhLine Clone();
01057     PhLine CloneToGroup(Group newParent);
01058 };
01059 
01060 
01062 class PhRect : public PhysicObject
01063 {
01064 public:
01066     Vector2D size;
01068     Vector2D GetSize();
01070     nil SetSize( Vector2D size);
01072     float sizeX;
01074     float sizeY;
01076     number GetSizeX();
01078     number GetSizeY();
01080     nil SetSizeX(number size);
01082     nil SetSizeY(number size);
01084     PhRect Clone();
01086     PhRect CloneToGroup(Group newParent);
01087 };
01088 
01089 
01091 class PhShape : public PhysicObject
01092 {
01093 public:
01095     Vector2D GetPoint(number nb);
01097     nil SetPoint(number nb,  Vector2D pt);
01099     nil AddPoint( Vector2D pt);
01101     nil RemovePoint(number nb);
01103     PhShape Clone();
01105     PhShape CloneToGroup(Group newParent);
01106 };
01107 
01108 
01110 class PhTriangle : public PhysicObject
01111 {
01112 public:
01114     Vector2D GetPoint(number nb);
01116     nil SetPoint(number nb,  Vector2D pt);
01118     PhTriangle Clone();
01120     PhTriangle CloneToGroup(Group newParent);
01121 };
01122 
01123 
01124 
01129 class PostFX : public Drawable
01130 {
01131 public:
01133     PostFX Clone();
01135     PostFX CloneToGroup(Group newParent);
01136     bool LoadFromFile( string Filename);
01138     nil SetParameter( string Name, number X);
01140     nil SetParameter( string Name, number X, number Y);
01142     nil SetParameter( string Name, number X, number Y, number Z);
01144     nil SetParameter( string Name, number X, number Y, number Z, number W);
01146     nil SetTexture( string Name, Texture Texture);
01148     bool static CanUsePostFX();
01149 };
01150 
01151 
01159 class Shape : public Drawable
01160 {
01161 public:
01163     Shape Clone();
01165     Shape CloneToGroup(Group newParent);
01167     Color color;
01169     nil SetColor( Color Col);
01171     Color GetColor();
01173     nil SetScale( Vector2D Scale);
01175     Vector2D GetScale();
01177     nil SetScaleX(number FactorX);
01179     nil SetScaleY(number FactorY);
01181     nil SetCenter( Vector2D Center);
01183     Vector2D GetCenter();
01184 // /** Add a point to the shape */
01186     nil AddPoint( Vector2D Position,  Color Col,  Color OutlineCol);
01188     number GetNbPoints();
01190     nil EnableFill(bool Enable);
01192     nil EnableOutline(bool Enable);
01194     nil SetPointPosition(number index,  Vector2D Position);
01196     nil SetPointColor(number index,  Color Col);
01198     nil SetPointOutlineColor(number index,  Color OutlineCol);
01200     nil SetOutlineWidth(number Width);
01202     Vector2D GetPointPosition(number index);
01204     Color GetPointColor(number index);
01206     Color GetPointOutlineColor(number index);
01208     number GetOutlineWidth();
01217     nil MakeLine( Vector2D P1,  Vector2D P2, number Thickness,  Color Col, number Outline,  Color OutlineCol);
01225     nil MakeRectangle( Vector2D P1,  Vector2D P2,  Color Col, number Outline,  Color OutlineCol);
01233     nil MakeCircle( Vector2D Center, number Radius,  Color Col, number Outline,  Color OutlineCol);
01235     nil SetSize(Vector2D size);
01236 };
01237 
01238 
01240 class Sprite : public Drawable
01241 {
01242 public:
01244     Sprite Clone();
01246     Sprite CloneToGroup(Group newParent);
01248     Vector2D size;
01250     Vector2D GetSize();
01252     nil SetSize( Vector2D newSize);
01254     nil SetImage( Texture Img);
01256     Color color;
01258     nil SetColor( Color Col);
01260     Color GetColor();
01262     nil SetScale( Vector2D Scale);
01264     Vector2D GetScale();
01266     nil SetScaleX(number FactorX);
01268     nil SetScaleY(number FactorY);
01270     nil SetCenter( Vector2D Center);
01272     Vector2D GetCenter();
01274     nil FlipX(bool Flipped);
01276     nil FlipY(bool Flipped);
01278     Color GetPixel(unsigned number X, unsigned number Y);
01279 };
01280 
01281 
01283 class Text : public Drawable
01284 {
01285 public:
01287     Text Clone();
01289     Text CloneToGroup(Group newParent);
01291     std::string text;
01293     nil SetText( string text);
01295     string GetText();
01297     Vector2D GetTextSize();
01299     float maxWidth;
01301     nil SetMaxWidth(number maxWidth);
01303     number GetMaxWidth();
01305     bool canCutWords;
01307     nil SetCutWords(bool cutWords);
01309     bool IsCutWords();
01311     Color color;
01313     nil SetColor( Color Col);
01315     Color GetColor();
01317     nil SetScale( Vector2D Scale);
01319     Vector2D GetScale();
01321     nil SetScaleX(number FactorX);
01323     nil SetScaleY(number FactorY);
01325     nil SetCenter( Vector2D Center);
01327     Vector2D GetCenter();
01329     nil SetFont( Font numberFont);
01331     Font GetFont();
01333     nil SetSize(number size);
01335     number GetSize();
01337     bool bold;
01339     nil SetBold(bool isBold);
01341     bool GetBold();
01343     bool italic;
01345     nil SetItalic(bool isItalic);
01347     bool GetItalic();
01349     bool underligned;
01351     nil SetUnderligned(bool isUnderligned);
01353     bool GetUnderligned();
01355     Vector2D GetCharacterPos(size_t Index);
01356 };
01357 
01358 
01362 class ScreenRenderer : public Drawable
01363 {
01364 public:
01366     ScreenRenderer Clone();
01368     ScreenRenderer CloneToGroup(Group newParent);
01370     Screen targetScreen;
01372     nil SetTargetScreen(Screen targetScreen);
01374     Screen GetTargetScreen();
01375 };
01376 
 All Classes Files Functions Variables