├── .gitignore ├── Changes.txt ├── LICENSE ├── README.md ├── Tools └── PhysicsEditor │ └── Custom_Exporter │ └── fantomEngine │ ├── exporter.xml │ └── fantomEngine.json ├── cftAStar.monkey ├── cftBox2D.monkey ├── cftEngine.monkey ├── cftFont.monkey ├── cftFunctions.monkey ├── cftGui.monkey ├── cftHighscore.monkey ├── cftImageMng.monkey ├── cftKeyMapping.monkey ├── cftLayer.monkey ├── cftLocalization.monkey ├── cftMisc.monkey ├── cftObjAnimMng.monkey ├── cftObject.monkey ├── cftRGBA.monkey ├── cftScene.monkey ├── cftSound.monkey ├── cftSpriteAtlas.monkey ├── cftSwipe.monkey ├── cftTileMap.monkey ├── cftTimer.monkey ├── cftTrans.monkey ├── cftTween.monkey ├── cftVec2D.monkey ├── cftWaypoints.monkey ├── data ├── ftLoadingBar.png ├── ftOrientation_changeL.png └── ftOrientation_changeP.png ├── docs ├── 3rdpartytools.html ├── cftAStar.monkey.html ├── cftBox2D.monkey.html ├── cftEngine.monkey.html ├── cftFont.monkey.html ├── cftFunctions.monkey.html ├── cftGui.monkey.html ├── cftHighscore.monkey.html ├── cftImageMng.monkey.html ├── cftKeyMapping.monkey.html ├── cftLayer.monkey.html ├── cftLocalization.monkey.html ├── cftMisc.monkey.html ├── cftObjAnimMng.monkey.html ├── cftObject.monkey.html ├── cftRGBA.monkey.html ├── cftScene.monkey.html ├── cftSound.monkey.html ├── cftSpriteAtlas.monkey.html ├── cftTileMap.monkey.html ├── cftTimer.monkey.html ├── cftTrans.monkey.html ├── cftVec2D.monkey.html ├── cftWaypoints.monkey.html ├── changes.html ├── classes.html ├── examples.html ├── index.html └── style.css ├── examples ├── BaseScript │ └── BaseScript.monkey ├── Canvas │ └── VirtualResolution │ │ └── VirtualResolution.monkey ├── Gui │ ├── Buttons │ │ ├── Buttons.data │ │ │ └── guiButton.png │ │ └── Buttons.monkey │ ├── Checkbox │ │ ├── Checkbox.data │ │ │ ├── chkBoxOff.png │ │ │ └── chkBoxOn.png │ │ └── Checkbox.monkey │ ├── Gui_Complete │ │ ├── Gui_Complete.data │ │ │ ├── chkBoxOff.png │ │ │ ├── chkBoxOn.png │ │ │ ├── font_20.png │ │ │ ├── font_20.txt │ │ │ ├── guiButton.png │ │ │ ├── guiChkBoxOff.png │ │ │ ├── guiChkBoxOn.png │ │ │ ├── guiJoyRing.png │ │ │ ├── guiJoyStick.png │ │ │ ├── guiSliderBar.png │ │ │ ├── guiSliderKnob.png │ │ │ ├── guiSwitchOff.png │ │ │ ├── guiSwitchOn.png │ │ │ └── lineContent.txt │ │ ├── Gui_Complete.monkey │ │ └── images │ │ │ ├── Gui.svg │ │ │ ├── Gui2.svg │ │ │ └── Gui3.svg │ ├── Joysticks │ │ ├── Joysticks.data │ │ │ ├── guiJoyRing.png │ │ │ └── guiJoyStick.png │ │ └── Joysticks.monkey │ ├── Label │ │ ├── Label.data │ │ │ ├── font_20.png │ │ │ └── font_20.txt │ │ └── Label.monkey │ ├── Listview │ │ ├── Listview.data │ │ │ ├── font_20.png │ │ │ ├── font_20.txt │ │ │ └── lineContent.txt │ │ └── Listview.monkey │ ├── Slider │ │ ├── Slider.data │ │ │ ├── font_20.png │ │ │ ├── font_20.txt │ │ │ ├── guiSliderBar.png │ │ │ └── guiSliderKnob.png │ │ └── Slider.monkey │ ├── Switch │ │ ├── Switch.data │ │ │ ├── guiSwitchOff.png │ │ │ └── guiSwitchOn.png │ │ └── Switch.monkey │ └── Textfield │ │ ├── Textfield.data │ │ ├── font_20.png │ │ └── font_20.txt │ │ └── Textfield.monkey ├── Input │ ├── KeyMapping │ │ └── KeyMapping.monkey │ ├── SwipeDetection │ │ ├── SwipeDetection.data │ │ │ ├── compass.png │ │ │ └── needle.png │ │ └── SwipeDetection.monkey │ └── TouchInput │ │ └── DragNDrop │ │ └── DragNDrop.monkey ├── Layer │ ├── ScalingLayers │ │ └── ScalingLayers.monkey │ └── ScrollingLayers │ │ └── ScrollingLayers.monkey ├── Localization │ ├── Localization.data │ │ ├── font.png │ │ ├── font.txt │ │ └── translation.txt │ └── Localization.monkey ├── Misc │ ├── MultiClass │ │ ├── MultiClass.monkey │ │ ├── customObjClass.monkey │ │ ├── engineClass.monkey │ │ ├── gameClass.monkey │ │ └── setupClass.monkey │ ├── RunJump │ │ └── RunJump.monkey │ └── UpdateObjects │ │ └── UpdateObjects.monkey ├── Objects │ ├── Appearance │ │ ├── BlendMode │ │ │ ├── BlendMode.data │ │ │ │ └── particle.png │ │ │ └── BlendMode.monkey │ │ └── FlashObject │ │ │ ├── FlashObject.monkey │ │ │ ├── FlashObject2.data │ │ │ ├── font.png │ │ │ └── font.txt │ │ │ └── FlashObject2.monkey │ ├── Behaviour │ │ └── ObjectMovement │ │ │ ├── ObjectMovement.monkey │ │ │ └── ObjectMovement2.monkey │ ├── Collision │ │ └── Collision.monkey │ ├── Creation │ │ ├── AnimObject │ │ │ ├── AnimObject.data │ │ │ │ ├── char_01.png │ │ │ │ ├── char_02.png │ │ │ │ ├── char_03.png │ │ │ │ ├── char_04.png │ │ │ │ ├── char_05.png │ │ │ │ ├── td_spritesheet.png │ │ │ │ └── td_spritesheet.txt │ │ │ ├── AnimObject.monkey │ │ │ └── character.svg │ │ ├── CopyObject │ │ │ └── CopyObject.monkey │ │ ├── CreatePrimitives │ │ │ └── CreatePrimitives.monkey │ │ ├── CustomObject │ │ │ └── CustomObject.monkey │ │ ├── LoadImage │ │ │ ├── LoadImage.data │ │ │ │ └── cratesmall.png │ │ │ └── LoadImage.monkey │ │ ├── PoolingObjects │ │ │ └── PoolingObjects.monkey │ │ └── RemoveObject │ │ │ ├── RemoveObject.data │ │ │ └── cratesmall.png │ │ │ └── RemoveObject.monkey │ ├── DataStorage │ │ └── DataStorage.monkey │ └── Hierachy │ │ ├── ParentChild │ │ └── ParentChild.monkey │ │ └── SortObjects │ │ └── SortObjects.monkey ├── Pathfinding │ └── Pathfinding.monkey ├── Physics │ ├── Box2DIntegration │ │ ├── Box2DIntegration.data │ │ │ └── cratesmall.png │ │ └── Box2DIntegration.monkey │ ├── Canon │ │ └── Canon.monkey │ ├── JuggleSoccerBall │ │ ├── JuggleSoccerBall.data │ │ │ ├── ball.png │ │ │ └── field.png │ │ └── JuggleSoccerBall.monkey │ ├── MouseJoint │ │ ├── MouseJoint.data │ │ │ └── cratesmall.png │ │ └── MouseJoint.monkey │ ├── Raycasting │ │ ├── Raycasting.data │ │ │ ├── ball.png │ │ │ └── cratesmall.png │ │ └── Raycasting.monkey │ └── RevoluteJoint │ │ ├── RevoluteJoint.data │ │ └── cratesmall.png │ │ └── RevoluteJoint.monkey ├── Scenes │ └── SceneCreation │ │ ├── SceneCreation.data │ │ ├── font.png │ │ └── font.txt │ │ └── SceneCreation.monkey ├── Sound │ ├── Sound.data │ │ ├── happy.mp3 │ │ └── shoot.wav │ └── Sound.monkey ├── SpriteSheets │ ├── SheetAnim │ │ ├── SheetAnim.data │ │ │ ├── spriteSheet.png │ │ │ └── spriteSheet.txt │ │ ├── SheetAnim.monkey │ │ └── spriteSheet.svg │ └── TexturePacker │ │ ├── TexturePacker.data │ │ ├── td_spritesheet.png │ │ └── td_spritesheet.txt │ │ └── TexturePacker.monkey ├── Text │ ├── FontMachine │ │ ├── FontMachine.data │ │ │ ├── SportsFont.txt │ │ │ ├── SportsFont_P_1.png │ │ │ └── SportsFont_P_2.png │ │ └── FontMachine.monkey │ └── MultilineText │ │ ├── MultilineText.data │ │ ├── font.png │ │ └── font.txt │ │ └── MultilineText.monkey ├── TileMaps │ ├── DynamicMap │ │ ├── DynamicMap.data │ │ │ └── tilesheet.png │ │ └── DynamicMap.monkey │ ├── EndlessMap │ │ └── EndlessMap.monkey │ ├── Platformer │ │ ├── Platformer.data │ │ │ ├── platformer.json │ │ │ └── tiles.png │ │ ├── Platformer.monkey │ │ └── tiles.svg │ ├── Platformer_Physics │ │ ├── Platformer_Physics.data │ │ │ ├── platformer.json │ │ │ ├── platformer2.json │ │ │ └── tiles.png │ │ └── Platformer_Physics.monkey │ └── Tiled │ │ ├── MultiTileSets.monkey │ │ ├── MultitileSets.data │ │ ├── font.png │ │ ├── font.txt │ │ └── maps │ │ │ ├── isometric_64x64.png │ │ │ ├── test_ortho_2tilesets.json │ │ │ ├── test_ortho_2tilesets.tmx │ │ │ ├── tiles1.png │ │ │ └── tiles2.png │ │ ├── Tiled.data │ │ ├── font.png │ │ ├── font.txt │ │ └── maps │ │ │ ├── desert.json │ │ │ ├── sewer.json │ │ │ ├── sewer_tileset.png │ │ │ └── tmw_desert_spacing.png │ │ ├── Tiled.monkey │ │ ├── TiledIsometric.data │ │ ├── font.png │ │ ├── font.txt │ │ └── maps │ │ │ ├── isometric_grass_and_water.json │ │ │ └── isometric_grass_and_water.png │ │ └── TiledIsometric.monkey ├── Timers │ └── Timers.monkey ├── Transitions │ └── ObjectTransition │ │ ├── ObjectTransition.monkey │ │ ├── ObjectTransitionImage.data │ │ └── image.png │ │ └── ObjectTransitionImage.monkey └── Waypoints │ ├── Waypoints.data │ └── CarSprite.png │ └── Waypoints.monkey ├── fantomEngine.monkey ├── fantomEngine_license.txt ├── monkeydoc ├── cftAStar.monkeydoc ├── cftBox2D.monkeydoc ├── cftEngine.monkeydoc ├── cftFont.monkeydoc ├── cftFunctions.monkeydoc ├── cftGui.monkeydoc ├── cftHighscore.monkeydoc ├── cftImageMng.monkeydoc ├── cftKeyMapping.monkeydoc ├── cftLayer.monkeydoc ├── cftLocalization.monkeydoc ├── cftMisc.monkeydoc ├── cftObjAnimMng.monkeydoc ├── cftObject.monkeydoc ├── cftRGBA.monkeydoc ├── cftScene.monkeydoc ├── cftSound.monkeydoc ├── cftSpriteAtlas.monkeydoc ├── cftTileMap.monkeydoc ├── cftTimer.monkeydoc ├── cftTrans.monkeydoc ├── cftVec2D.monkeydoc ├── cftWaypoints.monkeydoc └── fantomEngine.monkeydoc └── native ├── fantomengine.android.java ├── fantomengine.html5.js └── fantomengine.ios.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | /fantomEngine 2 | 3 | /fantomEngine/data/* 4 | 5 | /fantomEngine/docs/* 6 | !/fantomEngine/docs/fantomEngine.monkey.html 7 | 8 | /fantomEngine/examples/* 9 | 10 | /fantomEngine/monkeydoc/* 11 | 12 | /fantomEngine/native/* 13 | 14 | /fantomEngine/Tools/* 15 | !/fantomEngine/Tools/BMax_Conv/* 16 | !/fantomEngine/Tools/CleanOSXFiles/* 17 | !/fantomEngine/Tools/createrelease/* 18 | !/fantomEngine/Tools/DocMonk/* 19 | !/fantomEngine/Tools/TED_Help_Patcher/* 20 | 21 | !/fantomEngine/Todo* 22 | *.bak 23 | Tools/TED_Help_Patcher 24 | Tools/DocMonk 25 | CleanOSXFiles.ini 26 | Tools/CleanOSXFiles 27 | Tools/BMax_Conv 28 | Tools/createrelease 29 | fantomEngine.monkey.html 30 | docInclude 31 | docCode 32 | docParse 33 | ToDo_fantomEngineX.txt 34 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2016 Michael Hartlef 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ![fe_logo](http://files.whiteskygames.com/fe_logo_small.png) fantomEngine 2 | A 2D game framework for Monkey X 3 | 4 | ## Description 5 | [fantomEngine](http://www.fantomgl.com) is a 2D game framework (module) for [Monkey X](http://www.monkey-x.com) that was created to give game developers more time to work on the actual game play than on setting up render routines, update process chains and stuff like that. 6 | 7 | With fantomEngine you will write only fractions of the code you did before. 8 | 9 | ## Features 10 | 11 | fantomEngine provides a lot of feature like these: 12 | 13 | * Various objects like images, tile maps, graphic primitives, sounds, collision zones and layers. 14 | * Automatic processes to create, update and render objects. 15 | * **Callback methods** which are called during the handling of an object, layer, timer and transitions. 16 | * Layer **transitions** with callback methods. 17 | * Object transitions for position, rotation, scaling and alpha values with callback methods. 18 | * **Several equation and ease types for object and layer transitions**. 19 | * Object timers with callback methods. 20 | * **Different collision methods** with callback methods. 21 | * Touch input handling with callback methods. 22 | * Organize your objects in layers. 23 | * **Automatic content scaling** via providing a virtual canvas setup. 24 | * Simple **high-score** list loading, saving and updating. 25 | * Simple sound loading which handles the proper file extension depending on the chosen platform. 26 | * Support for **bitmap font text** objects which load EzGUI font descriptions. 27 | * Build-in frames per second calculator. 28 | * Extensive handling methods for the engine's objects. 29 | * Simple camera support which you can move around to render parts of your scenery. 30 | * Support for **texture maps** (atlas) created by the tool TexturePacker. 31 | * Support for **tile maps** created by the tool Tiled. 32 | * Engine time scaling supporting object updates, timers and transitions. 33 | * Automatic **swipe gesture detection** with event method. 34 | * Path/Waypoint handling. Let your objects follow them. 35 | * **A* pathfinding** und user definable grids of nodes. It doesn't have to be a grid of squares! 36 | * Easy **integration of Box2D** powered physics including ray casting. Physics definition created by the tool PhysicsEditor are supported too. 37 | * **Localize your game** easily with easy support of multiple languages. 38 | * Support different key maps for different controllers or user definitions. 39 | * Embedded objects inside a Tiled map will be stored and are accessable. 40 | * **Easy scene/room management**. 41 | * Objects can be composed of several single images. 42 | * **Automatic object pooling**. 43 | * **Custom GUI elements** 44 | -------------------------------------------------------------------------------- /Tools/PhysicsEditor/Custom_Exporter/fantomEngine/fantomEngine.json: -------------------------------------------------------------------------------- 1 | { 2 | "bodies":[ {% for body in bodies %}{% if not forloop.first %},{% endif %} 3 | { 4 | "name": "{{body.name}}", 5 | "isDynamic": {{body.dynamic}}, 6 | "isBullet": {{body.bullet}}, 7 | "fixedRotation": {{body.fixedRotation}}, 8 | "linearDamping": {{body.linearDamping}}, 9 | "angularDamping": {{body.angularDamping}}, 10 | "fixtures":[{% for fixture in body.fixtures %}{% if not forloop.first %},{% endif %}{% for polygon in fixture.polygons %}{% if not forloop.first %},{% endif %} 11 | { 12 | "density": {{fixture.density}}, 13 | "friction": {{fixture.friction}}, 14 | "restitution": {{fixture.bounce}}, 15 | "isSensor": {{fixture.isSensor}}, 16 | "filterGroupIndex": {{fixture.filter_groupIndex}}, 17 | "filter": { "categoryBits": {{fixture.filter_categoryBits}}, "maskBits": {{fixture.filter_maskBits}} }, 18 | "shape": [ {% for point in polygon %} {% if not forloop.first %}, {% endif %} {{point.x}}, {{point.y}} {% endfor %} ] 19 | } {% endfor %} {% endfor %} 20 | ] 21 | }{% endfor %} 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /cftKeyMapping.monkey: -------------------------------------------------------------------------------- 1 | #rem 2 | Title: fantomEngine 3 | Description: A 2D game framework for the Monkey programming language 4 | 5 | Author: Michael Hartlef 6 | Contact: michaelhartlef@gmail.com 7 | 8 | Website: http://www.fantomgl.com 9 | 10 | License: MIT 11 | #End 12 | 13 | 14 | 'nav:
15 | 16 | 'header:The module cftKeyMapping contains ... 17 | 18 | 19 | Import fantomEngine 20 | 21 | '*************************************** 22 | 'summery:The class [b]ftKeyMapping[/b] is an object which helps you supporting different key maps in your app. 23 | Class ftKeyMapping 24 | '#DOCOFF# 25 | Field keyMap:IntMap = Null 26 | '------------------------------------------ 27 | Method New() 28 | Self.keyMap = New IntMap 29 | End 30 | '#DOCON# 31 | '------------------------------------------ 32 | #Rem 33 | 'summery:This method clears all the mapping data. 34 | #End 35 | Method Clear:Void() 36 | Self.keyMap.Clear() 37 | End 38 | '------------------------------------------ 39 | #Rem 40 | 'summery:This method sets the mapping of a key code. 41 | #End 42 | 'seeAlso:GetKey,SafeToString 43 | Method SetKey:Void(keyCode:Int, mapCode:Int) 44 | Self.keyMap.Set(keyCode, mapCode) 45 | End 46 | '------------------------------------------ 47 | #Rem 48 | 'summery:This method returns the mapped key code. 49 | 'If no mapping is found, it will return the given key code. 50 | #End 51 | 'seeAlso:SetKey,LoadFromString 52 | Method GetKey:Int(keyCode:Int) 53 | Local retCode:Int = Self.keyMap.Get(keyCode) 54 | If retCode = 0 Then retCode = keyCode 55 | Return retCode 56 | End 57 | '------------------------------------------ 58 | #Rem 59 | 'summery:This method loads the keymapping class via a string 60 | 'The format of the string has to be (key;mappedKey~nkey;mappedKey...): 61 | '65;32 62 | '67;33 63 | #End 64 | 'seeAlso:SaveToString,GetKey 65 | Method LoadFromString:Void(mapStr:String) 66 | Self.Clear() 67 | Local lines := mapStr.Split("~n") 68 | For Local line:= Eachin lines 69 | If line = "" Then Continue 70 | Local ct$[] = line.Split(";") 71 | Local keyVal:Int = Int(ct[0]) 72 | Local mapVal:Int = Int(ct[1]) 73 | Self.SetKey(keyVal,mapVal) 74 | Next 75 | End 76 | 77 | 78 | '------------------------------------------ 79 | #Rem 80 | 'summery:This method saves the key mapping data to a string. 81 | #End 82 | 'seeAlso:LoadFromString,SetKey 83 | Method SaveToString:String() 84 | Local retStr:String="" 85 | For Local item:= Eachin Self.keyMap 86 | retStr = retStr + item.Key() + ";" + item.Value() + "~n" 87 | Next 88 | Return retStr 89 | End 90 | End 91 | 92 | #rem 93 | footer:This fantomEngine framework is released under the MIT license: 94 | [quote]Copyright (c) 2011-2016 Michael Hartlef 95 | 96 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the software, and to permit persons to whom the software is furnished to do so, subject to the following conditions: 97 | 98 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the software. 99 | 100 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 101 | [/quote] 102 | #end -------------------------------------------------------------------------------- /cftMisc.monkey: -------------------------------------------------------------------------------- 1 | '#DOCON# 2 | #rem 3 | Title: fantomEngine 4 | Description: A 2D game framework for the Monkey programming language 5 | 6 | Author: Michael Hartlef 7 | Contact: michaelhartlef@gmail.com 8 | 9 | Website: http://www.fantomgl.com 10 | 11 | License: MIT 12 | #End 13 | 14 | 15 | 'nav:
16 | 17 | Import fantomEngine 18 | '#DOCOFF# 19 | '------------------------------------------ 20 | Function XWA:Int (_dummy:Int) 21 | Return 0 22 | End 23 | 24 | '------------------------------------------ 25 | Function _CalculateCatmull:ftVec2D(t:Float, p0:ftVec2D, p1:ftVec2D, p2:ftVec2D, p3:ftVec2D ) 26 | Local ret:ftVec2D = New ftVec2D 27 | ret.x = 0.5 *((2.0*p1.x) + (p2.x-p0.x)*t + (2.0*p0.x-5.0*p1.x+4.0*p2.x-p3.x)*t*t + (3.0*p1.x-p0.x-3.0*p2.x+p3.x)*t*t*t) 'X 28 | ret.y = 0.5 *((2.0*p1.y) + (p2.y-p0.y)*t + (2.0*p0.y-5.0*p1.y+4.0*p2.y-p3.y)*t*t + (3.0*p1.y-p0.y-3.0*p2.y+p3.y)*t*t*t) 'Y 29 | Return ret 30 | End Function 31 | '------------------------------------------ 32 | #rem 33 | summery: This funtion rotates the display. 34 | It is for internal purposes only. 35 | #end 36 | Function RotateDisplay:Void (X:Float, Y:Float, angle:Float) 37 | 'PushMatrix ' Store current rotation, scale, etc 38 | Translate X, Y ' Shift origin across to here 39 | Rotate angle ' Rotate around origin 40 | Translate -X, -Y ' Shift origin back where it was 41 | 'Return 0 42 | End 43 | '------------------------------------------ 44 | '#DOCON# 45 | #Rem 46 | 'summery:Calculates the pitchrate for the amount of given halfsteps. 47 | The default base note is 'A4' 48 | #End 49 | Function GetPitchRate:Float(halfStep:Float, base:Float=1.0) 50 | 'Pow(2.0,1.0/12.0) = 1.0594630943592953 51 | Local pr:Float = Pow(1.0594630943592953,halfStep) * base 52 | Return pr 53 | End 54 | 55 | '#DOCOFF# 56 | '*************************************** 57 | Class tPointS 58 | Field x:Float 59 | Field y:Float 60 | End 61 | '*************************************** 62 | Class tLine2D 63 | Field p1:tPointS 64 | Field p2:tPointS 65 | '------------------------------------------ 66 | Method New() 67 | p1 = New tPointS 68 | p2 = New tPointS 69 | End 70 | End 71 | 72 | 73 | '#DOCON# 74 | 75 | 76 | 77 | #rem 78 | footer:This fantomEngine framework is released under the MIT license: 79 | [quote]Copyright (c) 2011-2016 Michael Hartlef 80 | 81 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the software, and to permit persons to whom the software is furnished to do so, subject to the following conditions: 82 | 83 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the software. 84 | 85 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 86 | [/quote] 87 | #end -------------------------------------------------------------------------------- /data/ftLoadingBar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/data/ftLoadingBar.png -------------------------------------------------------------------------------- /data/ftOrientation_changeL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/data/ftOrientation_changeL.png -------------------------------------------------------------------------------- /data/ftOrientation_changeP.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/data/ftOrientation_changeP.png -------------------------------------------------------------------------------- /docs/cftFont.monkey.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | fantomEngine.cftFont 9 | 10 | 11 |

Module fantomEngine.cftFont


The module cftFont hosts several classes which add bitmap font drawing to fantomEngine. Bitmap fonts are important if you need to show text information inside your game fast and easy.

Table of contents:

Classes:

Class ftFont
Description:The class ftFont provides a few methods regarding the definition of a loaded font.
Table of contents:Methods:
  • Height   ( Method Height:Int() )
  • Length   ( Method Length:Int(t:String) )

Method Height:Int()

Syntax:


Int = ftFont.Height ()
Description:Returns the maximum height of the font.
Return type:Int
See also:Height
Method Length:Int(t:String)

Syntax:


Int = ftFont.Length (t:String)
Description:Returns the length in pixel of the given text string.
Return type:Int
Parameters:
NameTypeValue
tString
See also:Length
This fantomEngine framework is released under the MIT license:
Copyright (c) 2011-2016 Michael Hartlef

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the software, and to permit persons to whom the software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

12 | 13 | -------------------------------------------------------------------------------- /docs/cftMisc.monkey.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | fantomEngine.cftMisc 9 | 10 | 11 |

Module fantomEngine.cftMisc


Table of contents:

Functions:

Function GetPitchRate:Float(halfStep:Float, base:Float=1.0)

Syntax:

Float = GetPitchRate (halfStep:Float, base:Float=1.0)
Description:Calculates the pitchrate for the amount of given halfsteps.
Return type:Float
Parameters:
NameTypeValue
halfStepFloat
baseFloat1.0
Details:The default base note is 'A4'
This fantomEngine framework is released under the MIT license:
Copyright (c) 2011-2016 Michael Hartlef

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the software, and to permit persons to whom the software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

12 | 13 | -------------------------------------------------------------------------------- /docs/cftTimer.monkey.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | fantomEngine.cftTimer 9 | 10 | 11 |

Module fantomEngine.cftTimer


The class ftTimer handles ftEngine and ftObject timer objects.

Table of contents:

Classes:

Class ftTimer
Table of contents:Methods:
  • GetPaused   ( Method GetPaused:Bool() )
  • RemoveTimer   ( Method RemoveTimer:Void() )
  • SetPaused   ( Method SetPaused:Void(pauseFlag:Bool = True) )

Method GetPaused:Bool()

Syntax:


Bool = ftTimer.GetPaused ()
Description:Returns TRUE if a transition is paused.
Return type:Bool
See also:SetPaused
Method RemoveTimer:Void()

Syntax:


ftTimer.RemoveTimer ()
Description:With this method removes the timer.
Method SetPaused:Void(pauseFlag:Bool = True)

Syntax:


ftTimer.SetPaused (pauseFlag:Bool = True)
Description:With this method you can pause and resume the timer.
Parameters:
NameTypeValue
pauseFlagBoolTrue
See also:GetPaused , Update
This fantomEngine framework is released under the MIT license:
Copyright (c) 2011-2016 Michael Hartlef

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the software, and to permit persons to whom the software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

12 | 13 | -------------------------------------------------------------------------------- /docs/style.css: -------------------------------------------------------------------------------- 1 | #cssmenu { 2 | zoom: 1; 3 | width: auto; 4 | background: #000000; 5 | padding: 8px 0; 6 | } 7 | #cssmenu:before { 8 | content: ''; 9 | display: block; 10 | } 11 | #cssmenu:after { 12 | content: ''; 13 | display: table; 14 | clear: both; 15 | } 16 | #cssmenu ul { 17 | list-style-type: none; 18 | position: relative; 19 | display: block; 20 | font-size: 12px; 21 | font-family: Verdana, Helvetica, Arial, sans-serif; 22 | margin: 0; 23 | padding: 0; 24 | border-bottom: 1px solid #7ab900; 25 | zoom: 1; 26 | } 27 | #cssmenu ul:before { 28 | content: ''; 29 | display: block; 30 | } 31 | #cssmenu ul:after { 32 | content: ''; 33 | display: table; 34 | clear: both; 35 | } 36 | #cssmenu li { 37 | display: block; 38 | float: left; 39 | margin: 0; 40 | padding: 0; 41 | } 42 | #cssmenu li a { 43 | float: left; 44 | color: #A79787; 45 | text-decoration: none; 46 | height: 24px; 47 | padding: 9px 15px 0; 48 | font-weight: normal; 49 | } 50 | #cssmenu li:hover, 51 | #cssmenu .active { 52 | text-decoration: none; 53 | border-bottom: 2px solid #7ab900; 54 | } 55 | #cssmenu li:hover a { 56 | color: #fff; 57 | } 58 | #cssmenu .active a { 59 | color: #fff; 60 | font-weight: 700; 61 | } 62 | 63 | 64 | 65 | 66 | 67 | body { 68 | margin: 15px 50px 15px 50px; 69 | font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif,"Century Gothic"; 70 | font-size: small; 71 | vertical-align: top; 72 | } 73 | table { 74 | box-shadow: 0px 0px 5px 0px; 75 | border-radius: 5px; 76 | line-height: normal; 77 | border: 1px solid #C0C0C0; 78 | vertical-align: top; 79 | margin-bottom: 30px; 80 | } 81 | 82 | .fchanges { 83 | color: #FF0000; 84 | font-style: italic; 85 | } 86 | 87 | h4 { font-size:120%; 88 | color:#0000AA; 89 | border-bottom:solid thin black; } 90 | 91 | h3 { font-size:150%; 92 | color:#FFFFFF; 93 | border-radius: 10px; 94 | padding: 5px 5px 5px 50px; 95 | font-style:italic; 96 | background-color: #999999; 97 | } 98 | 99 | h2 { font-size:200%; 100 | border-radius: 10px; 101 | padding: 5px 0px 5px 5px; 102 | border: 1px solid #E8E8E8; 103 | font-style: italic; 104 | color: #333333; 105 | background-color: #D7E7FF; 106 | box-shadow: 0px 0px 0px 0px; 107 | margin-right:0px; 108 | margin-left:0px; 109 | text-align:Left; 110 | } 111 | 112 | h1 { font-size:250%; 113 | color:#000000;} 114 | 115 | tbody { 116 | } 117 | .tablehead { 118 | background-color: #333333; 119 | color: #FFFFFF; 120 | line-height: 26px; 121 | font-weight: bold; 122 | } 123 | .subtablehead { 124 | background-color: #D7E7FF; 125 | color: #333333; 126 | line-height: 26px; 127 | font-weight: normal; 128 | } 129 | 130 | blockquote { 131 | border-radius: 10px; 132 | padding: 10px 0px 10px 10px; 133 | border: 1px solid #E8E8E8; 134 | font-style: italic; 135 | color: #333333; 136 | background-color: #D7E7FF; 137 | box-shadow: 0px 0px 0px 0px; 138 | margin-right:0px; 139 | margin-left:0px; 140 | } 141 | 142 | a { 143 | color: #000066; 144 | } 145 | a:active { 146 | color: #000066; 147 | } 148 | a:hover { 149 | background-color: #CCCCCC; 150 | } 151 | a:link { 152 | color: #000066; 153 | } 154 | a:visited { 155 | color: #000066; 156 | } 157 | pre { 158 | border-radius: 5px; 159 | padding: 15px; 160 | font-family: "Consolas", "Courier New", Courier, monospace; 161 | color: #FFFFFF; 162 | background-color: #000033; 163 | font-size: 13px; 164 | } 165 | .subtable { 166 | border: 1px solid #C0C0C0; 167 | border-radius: 0px; 168 | box-shadow: 0px 0px 0px 0px; 169 | 170 | /* margin: 5px 5px 5px 55px;*/ 171 | } 172 | td { 173 | padding: 3px 25px 3px 15px; 174 | vertical-align: top; 175 | } 176 | 177 | th { 178 | padding: 3px 25px 3px 15px; 179 | background-color: #aaaaaa; 180 | font-size: 12px; 181 | color: #ffffff; 182 | vertical-align: top; 183 | font-weight: normal; 184 | } 185 | 186 | 187 | .footer { 188 | font-size: x-small; 189 | text-align: center; 190 | color: #333333; 191 | } 192 | -------------------------------------------------------------------------------- /examples/Canvas/VirtualResolution/VirtualResolution.monkey: -------------------------------------------------------------------------------- 1 | Strict 2 | 3 | #rem 4 | Script: VirtualResolution.monkey 5 | Description: A sample script to show how to deal with a virtual canvas size/resolution 6 | Author: Michael Hartlef 7 | Version: 1.01 8 | #End 9 | 10 | ' Import the fantomEngine framework which imports mojo itself 11 | Import fantomEngine 12 | 13 | ' The _g variable holds an instance to the cGame class 14 | Global _g:cGame 15 | 16 | '*************************************** 17 | ' The cGame class controls the app 18 | Class cGame Extends App 19 | ' Create a field to store the instance of the cEngine class, which is an instance 20 | ' of the ftEngine class itself 21 | Field fE:cEngine 22 | 23 | '------------------------------------------ 24 | Method OnCreate:Int() 25 | ' Set the update rate of Mojo's OnUpdate to 60 FPS. 26 | SetUpdateRate(60) 27 | 28 | ' Create an instance of the fantomEngine, which was created via the cEngine class 29 | fE = New cEngine 30 | 31 | ' Now set the virtual fixed resolution. We use LetterBox scaling. 32 | fE.SetCanvasSize(960, 640, ftEngine.cmLetterbox) 33 | 34 | ' Lastly create a yellow box of the size of the virtual canvas and center it so it will cover the whole virtual canvas 35 | Local box := fE.CreateBox(960, 640, fE.GetCanvasWidth()/2.0, fE.GetCanvasHeight()/2.0) 36 | box.SetColor(255,255,0) 37 | 38 | 39 | Return 0 40 | End 41 | '------------------------------------------ 42 | Method OnUpdate:Int() 43 | ' If the CLOSE key was hit, exit the app ... needed for GLFW and Android I think. 44 | If KeyHit( KEY_CLOSE ) Then fE.ExitApp() 45 | 46 | ' Determine the delta time and the update factor for the engine 47 | Local timeDelta:Float = Float(fE.CalcDeltaTime())/60.0 48 | 49 | ' Update all objects of the engine 50 | If fE.GetPaused() = False Then 51 | fE.Update(timeDelta) 52 | Endif 53 | Return 0 54 | End 55 | '------------------------------------------ 56 | Method OnRender:Int() 57 | ' Create 2 variables that store local coordinates 58 | Local lX:Int 59 | Local lY:Int 60 | 61 | ' For the upcomming drawing call we need to calculate the real (local) coordinates from our world (virtual) coordinates 62 | lX = fE.GetLocalX(20) 63 | lY = fE.GetLocalY(20) 64 | 65 | ' Check if the engine is not paused 66 | If fE.GetPaused() = False Then 67 | ' Clear the screen to a bright RED 68 | Cls 255,0,0 69 | 70 | ' Render all visible objects of the engine 71 | fE.Render() 72 | 73 | ' Now draw the current FPS value in the top left corner of the canvas 74 | DrawText( "FPS= "+fE.GetFPS(), lX, lY) 75 | Else 76 | ' Clear the screen to a bright BLUE 77 | Cls 0,0,255 78 | 79 | 80 | ' Now draw the a PAUSE message the top left corner of the canvas 81 | DrawText( "**** Game is paused ****", lX, lY) 82 | 83 | Endif 84 | Return 0 85 | End 86 | '------------------------------------------ 87 | Method OnResume:Int() 88 | ' Set the pause flag of the engine to FALSE so objects, timers and transitions are updated again 89 | fE.SetPaused(False) 90 | 91 | Return 0 92 | End 93 | '------------------------------------------ 94 | Method OnSuspend:Int() 95 | ' Set the pause flag of the engine to TRUE so objects, timers and transitions are paused (not updated) 96 | fE.SetPaused(True) 97 | 98 | Return 0 99 | End 100 | End 101 | 102 | '*************************************** 103 | ' The cEngine class extends the ftEngine class to override the On... methods 104 | Class cEngine Extends ftEngine 105 | ' nothing happens here 106 | End 107 | 108 | '*************************************** 109 | Function Main:Int() 110 | ' Create an instance of the cGame class and store it inside the global var 'g' 111 | _g = New cGame 112 | 113 | Return 0 114 | End 115 | 116 | -------------------------------------------------------------------------------- /examples/Gui/Buttons/Buttons.data/guiButton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Gui/Buttons/Buttons.data/guiButton.png -------------------------------------------------------------------------------- /examples/Gui/Checkbox/Checkbox.data/chkBoxOff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Gui/Checkbox/Checkbox.data/chkBoxOff.png -------------------------------------------------------------------------------- /examples/Gui/Checkbox/Checkbox.data/chkBoxOn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Gui/Checkbox/Checkbox.data/chkBoxOn.png -------------------------------------------------------------------------------- /examples/Gui/Gui_Complete/Gui_Complete.data/chkBoxOff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Gui/Gui_Complete/Gui_Complete.data/chkBoxOff.png -------------------------------------------------------------------------------- /examples/Gui/Gui_Complete/Gui_Complete.data/chkBoxOn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Gui/Gui_Complete/Gui_Complete.data/chkBoxOn.png -------------------------------------------------------------------------------- /examples/Gui/Gui_Complete/Gui_Complete.data/font_20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Gui/Gui_Complete/Gui_Complete.data/font_20.png -------------------------------------------------------------------------------- /examples/Gui/Gui_Complete/Gui_Complete.data/guiButton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Gui/Gui_Complete/Gui_Complete.data/guiButton.png -------------------------------------------------------------------------------- /examples/Gui/Gui_Complete/Gui_Complete.data/guiChkBoxOff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Gui/Gui_Complete/Gui_Complete.data/guiChkBoxOff.png -------------------------------------------------------------------------------- /examples/Gui/Gui_Complete/Gui_Complete.data/guiChkBoxOn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Gui/Gui_Complete/Gui_Complete.data/guiChkBoxOn.png -------------------------------------------------------------------------------- /examples/Gui/Gui_Complete/Gui_Complete.data/guiJoyRing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Gui/Gui_Complete/Gui_Complete.data/guiJoyRing.png -------------------------------------------------------------------------------- /examples/Gui/Gui_Complete/Gui_Complete.data/guiJoyStick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Gui/Gui_Complete/Gui_Complete.data/guiJoyStick.png -------------------------------------------------------------------------------- /examples/Gui/Gui_Complete/Gui_Complete.data/guiSliderBar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Gui/Gui_Complete/Gui_Complete.data/guiSliderBar.png -------------------------------------------------------------------------------- /examples/Gui/Gui_Complete/Gui_Complete.data/guiSliderKnob.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Gui/Gui_Complete/Gui_Complete.data/guiSliderKnob.png -------------------------------------------------------------------------------- /examples/Gui/Gui_Complete/Gui_Complete.data/guiSwitchOff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Gui/Gui_Complete/Gui_Complete.data/guiSwitchOff.png -------------------------------------------------------------------------------- /examples/Gui/Gui_Complete/Gui_Complete.data/guiSwitchOn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Gui/Gui_Complete/Gui_Complete.data/guiSwitchOn.png -------------------------------------------------------------------------------- /examples/Gui/Gui_Complete/Gui_Complete.data/lineContent.txt: -------------------------------------------------------------------------------- 1 | Line #1 12345648901234567890 2 | Line #2 12345648901234567890 3 | Line #3 12345648901234567890 4 | Line #4 12345648901234567890 5 | Line #5 12345648901234567890 6 | Line #6 12345648901234567890 7 | Line #7 12345648901234567890 8 | Line #8 12345648901234567890 9 | Line #9 12345648901234567890 10 | Line #10 12345648901234567890 11 | Line #11 12345648901234567890 12 | Line #12 12345648901234567890 13 | Line #13 12345648901234567890 14 | Line #14 12345648901234567890 15 | Line #15 12345648901234567890 16 | Line #16 12345648901234567890 17 | Line #17 12345648901234567890 18 | Line #18 12345648901234567890 19 | Line #19 12345648901234567890 20 | Line #20 12345648901234567890 -------------------------------------------------------------------------------- /examples/Gui/Gui_Complete/images/Gui3.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 20 | 38 | 45 | 46 | 48 | 49 | 51 | image/svg+xml 52 | 54 | 55 | 56 | 57 | 58 | 63 | 71 | 78 | 85 | 92 | 93 | 98 | 99 | -------------------------------------------------------------------------------- /examples/Gui/Joysticks/Joysticks.data/guiJoyRing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Gui/Joysticks/Joysticks.data/guiJoyRing.png -------------------------------------------------------------------------------- /examples/Gui/Joysticks/Joysticks.data/guiJoyStick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Gui/Joysticks/Joysticks.data/guiJoyStick.png -------------------------------------------------------------------------------- /examples/Gui/Label/Label.data/font_20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Gui/Label/Label.data/font_20.png -------------------------------------------------------------------------------- /examples/Gui/Label/Label.monkey: -------------------------------------------------------------------------------- 1 | Strict 2 | 3 | #rem 4 | Script: Label.monkey 5 | Description: fantomEngine sample script that shows how to use the custom gui label object 6 | Author: Michael Hartlef 7 | Version: 1.0 8 | #End 9 | 10 | ' Set the AutoSuspend functionality to TRUE so OnResume/OnSuspend are called 11 | #MOJO_AUTO_SUSPEND_ENABLED=True 12 | #MOJO_IMAGE_FILTERING_ENABLED=FALSE 13 | 14 | ' Import the fantomEngine framework which imports mojo itself 15 | Import fantomEngine 16 | 17 | ' The _g variable holds an instance to the cGame class 18 | Global _g:cGame 19 | 20 | '*************************************** 21 | ' The cGame class controls the app 22 | Class cGame Extends App 23 | ' Create a field to store the instance of the cEngine class, which is an instance 24 | ' of the ftEngine class itself 25 | Field fE:cEngine 26 | 27 | ' Create a field for the default scene and layer of the engine 28 | Field defLayer:ftLayer 29 | Field defScene:ftScene 30 | 31 | Field guiMng:ftGuiMng = Null 32 | Field guiLabel:ftGuiLabel = Null 33 | 34 | Field font1:ftFont 35 | 36 | '------------------------------------------ 37 | Method OnClose:Int() 38 | fE.ExitApp() 39 | Return 0 40 | End 41 | '------------------------------------------ 42 | Method OnBack:Int() 43 | Return 0 44 | End 45 | '------------------------------------------ 46 | Method OnCreate:Int() 47 | 48 | Local x:Float 49 | Local y:Float 50 | 51 | ' Set the update rate to the maximum FPS of the device 52 | SetUpdateRate(60) 53 | 54 | fE = New cEngine 55 | fE.SetCanvasSize(640,480) 56 | 57 | font1 = fE.LoadFont("font_20") 58 | 59 | guiMng = fE.CreateGUI() 60 | guiMng.font1 = font1 61 | 62 | guiLabel = guiMng.CreateLabel("FPS: 60",True) 63 | guiLabel.SetPos(20, fE.GetCanvasHeight()/2) 64 | 65 | 66 | ' Get the default scene of the engine 67 | defScene = fE.GetDefaultScene() 68 | 69 | ' Get the default layer of the engine 70 | defLayer = fE.GetDefaultLayer() 71 | 'defLayer.SetAlpha(0.8) 72 | 73 | Return 0 74 | End 75 | '------------------------------------------ 76 | Method OnUpdate:Int() 77 | ' If the CLOSE key was hit, exit the app ... needed for GLFW and Android I think. 78 | If KeyHit( KEY_ESCAPE ) Then fE.ExitApp() 79 | 80 | ' Determine the delta time and the update factor for the engine 81 | Local timeDelta:Float = Float(fE.CalcDeltaTime())/60.0 82 | 83 | ' Update all objects of the engine 84 | If fE.GetPaused() = False Then 85 | fE.Update(timeDelta) 86 | ' Do a touch check for the first 4 fingers 87 | For Local index:Int = 0 To 3 88 | If TouchDown(index) Then fE.TouchCheck(index) 89 | Next 90 | Endif 91 | 92 | 93 | 94 | Return 0 95 | End 96 | '------------------------------------------ 97 | Method OnRender:Int() 98 | ' Check if the engine is not paused 99 | If fE.GetPaused() = False 100 | ' Clear the screen 101 | Cls 200,0,0 102 | ' Render all visible objects of the engine 103 | fE.Render() 104 | Else 105 | DrawText("**** PAUSED ****",fE.GetLocalX(fE.GetCanvasWidth()/2.0),fE.GetLocalY(fE.GetCanvasHeight()/2.0),0.5, 0.5) 106 | Endif 107 | Return 0 108 | End 109 | '------------------------------------------ 110 | Method OnLoading:Int() 111 | ' If loading of assets in OnCreate takes longer, render a simple loading screen 112 | fE.RenderLoadingBar() 113 | 114 | Return 0 115 | End 116 | '------------------------------------------ 117 | Method OnResume:Int() 118 | ' Set the pause flag of the engine to FALSE so objects, timers and transitions are updated again 119 | fE.SetPaused(False) 120 | 121 | Return 0 122 | End 123 | '------------------------------------------ 124 | Method OnSuspend:Int() 125 | ' Set the pause flag of the engine to TRUE so objects, timers and transitions are paused (not updated) 126 | fE.SetPaused(True) 127 | 128 | Return 0 129 | End 130 | End 131 | 132 | '*************************************** 133 | ' The cEngine class extends the ftEngine class to override the On... methods 134 | Class cEngine Extends ftEngine 135 | '------------------------------------------ 136 | 'Callback method which is called when a layer is updated. 137 | Method OnLayerUpdate:Int(layer:ftLayer) 138 | _g.guiLabel.SetText("FPS: "+_g.fE.GetFPS()) 139 | '_g.guiLabel.SetText("FPS: 60"+"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") 140 | Return 0 141 | End 142 | End 143 | 144 | '*************************************** 145 | Function Main:Int() 146 | ' Create an instance of the cGame class and store it inside the global var 'g' 147 | _g = New cGame 148 | 149 | Return 0 150 | End 151 | 152 | -------------------------------------------------------------------------------- /examples/Gui/Listview/Listview.data/font_20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Gui/Listview/Listview.data/font_20.png -------------------------------------------------------------------------------- /examples/Gui/Listview/Listview.data/lineContent.txt: -------------------------------------------------------------------------------- 1 | Line #1 12345648901234567890 2 | Line #2 12345648901234567890 3 | Line #3 12345648901234567890 4 | Line #4 12345648901234567890 5 | Line #5 12345648901234567890 6 | Line #6 12345648901234567890 7 | Line #7 12345648901234567890 8 | Line #8 12345648901234567890 9 | Line #9 12345648901234567890 10 | Line #10 12345648901234567890 11 | Line #11 12345648901234567890 12 | Line #12 12345648901234567890 13 | Line #13 12345648901234567890 14 | Line #14 12345648901234567890 15 | Line #15 12345648901234567890 16 | Line #16 12345648901234567890 17 | Line #17 12345648901234567890 18 | Line #18 12345648901234567890 19 | Line #19 12345648901234567890 20 | Line #20 12345648901234567890 -------------------------------------------------------------------------------- /examples/Gui/Slider/Slider.data/font_20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Gui/Slider/Slider.data/font_20.png -------------------------------------------------------------------------------- /examples/Gui/Slider/Slider.data/guiSliderBar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Gui/Slider/Slider.data/guiSliderBar.png -------------------------------------------------------------------------------- /examples/Gui/Slider/Slider.data/guiSliderKnob.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Gui/Slider/Slider.data/guiSliderKnob.png -------------------------------------------------------------------------------- /examples/Gui/Switch/Switch.data/guiSwitchOff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Gui/Switch/Switch.data/guiSwitchOff.png -------------------------------------------------------------------------------- /examples/Gui/Switch/Switch.data/guiSwitchOn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Gui/Switch/Switch.data/guiSwitchOn.png -------------------------------------------------------------------------------- /examples/Gui/Textfield/Textfield.data/font_20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Gui/Textfield/Textfield.data/font_20.png -------------------------------------------------------------------------------- /examples/Gui/Textfield/Textfield.monkey: -------------------------------------------------------------------------------- 1 | Strict 2 | 3 | #rem 4 | Script: Textfield.monkey 5 | Description: fantomEngine sample script that shows how to use the custom gui textfield object 6 | Author: Michael Hartlef 7 | Version: 1.0 8 | #End 9 | 10 | ' Set the AutoSuspend functionality to TRUE so OnResume/OnSuspend are called 11 | #MOJO_AUTO_SUSPEND_ENABLED=True 12 | #MOJO_IMAGE_FILTERING_ENABLED=FALSE 13 | 14 | ' Import the fantomEngine framework which imports mojo itself 15 | Import fantomEngine 16 | 17 | ' The _g variable holds an instance to the cGame class 18 | Global _g:cGame 19 | 20 | '*************************************** 21 | ' The cGame class controls the app 22 | Class cGame Extends App 23 | ' Create a field to store the instance of the cEngine class, which is an instance 24 | ' of the ftEngine class itself 25 | Field fE:cEngine 26 | 27 | ' Create a field for the default scene and layer of the engine 28 | Field defLayer:ftLayer 29 | Field defScene:ftScene 30 | 31 | Field guiMng:ftGuiMng = Null 32 | Field guiTextfield:ftGuiTextfield = Null 33 | 34 | Field font1:ftFont 35 | 36 | '------------------------------------------ 37 | Method OnClose:Int() 38 | fE.ExitApp() 39 | Return 0 40 | End 41 | '------------------------------------------ 42 | Method OnBack:Int() 43 | Return 0 44 | End 45 | '------------------------------------------ 46 | Method OnCreate:Int() 47 | 48 | Local x:Float 49 | Local y:Float 50 | 51 | ' Set the update rate to the maximum FPS of the device 52 | SetUpdateRate(60) 53 | 54 | fE = New cEngine 55 | fE.SetCanvasSize(640,480) 56 | 57 | font1 = fE.LoadFont("font_20") 58 | 59 | guiMng = fE.CreateGUI() 60 | guiMng.font1 = font1 61 | 62 | guiTextfield = guiMng.CreateTextfield("Type here...",True) 63 | guiTextfield.SetPos(20, fE.GetCanvasHeight()/2) 64 | 65 | 66 | ' Get the default scene of the engine 67 | defScene = fE.GetDefaultScene() 68 | 69 | ' Get the default layer of the engine 70 | defLayer = fE.GetDefaultLayer() 71 | 'defLayer.SetAlpha(0.8) 72 | 73 | Return 0 74 | End 75 | '------------------------------------------ 76 | Method OnUpdate:Int() 77 | ' If the CLOSE key was hit, exit the app ... needed for GLFW and Android I think. 78 | If KeyHit( KEY_ESCAPE ) Then fE.ExitApp() 79 | 80 | ' Determine the delta time and the update factor for the engine 81 | Local timeDelta:Float = Float(fE.CalcDeltaTime())/60.0 82 | 83 | ' Update all objects of the engine 84 | If fE.GetPaused() = False Then 85 | fE.Update(timeDelta) 86 | ' Do a touch check for the first 4 fingers 87 | For Local index:Int = 0 To 3 88 | If TouchDown(index) Then fE.TouchCheck(index) 89 | Next 90 | Endif 91 | 92 | 93 | 94 | Return 0 95 | End 96 | '------------------------------------------ 97 | Method OnRender:Int() 98 | ' Check if the engine is not paused 99 | If fE.GetPaused() = False 100 | ' Clear the screen 101 | Cls 200,0,0 102 | ' Render all visible objects of the engine 103 | fE.Render() 104 | SetAlpha(1.0) 105 | ' Draw the current FramesPerSecond value to the canvas 106 | DrawText("FPS: "+fE.GetFPS(), Int(fE.GetLocalX(20)),Int(fE.GetLocalY(10))) 107 | fE.RestoreAlpha() 108 | Else 109 | DrawText("**** PAUSED ****",fE.GetLocalX(fE.GetCanvasWidth()/2.0),fE.GetLocalY(fE.GetCanvasHeight()/2.0),0.5, 0.5) 110 | Endif 111 | Return 0 112 | End 113 | '------------------------------------------ 114 | Method OnLoading:Int() 115 | ' If loading of assets in OnCreate takes longer, render a simple loading screen 116 | fE.RenderLoadingBar() 117 | 118 | Return 0 119 | End 120 | '------------------------------------------ 121 | Method OnResume:Int() 122 | ' Set the pause flag of the engine to FALSE so objects, timers and transitions are updated again 123 | fE.SetPaused(False) 124 | 125 | Return 0 126 | End 127 | '------------------------------------------ 128 | Method OnSuspend:Int() 129 | ' Set the pause flag of the engine to TRUE so objects, timers and transitions are paused (not updated) 130 | fE.SetPaused(True) 131 | 132 | Return 0 133 | End 134 | End 135 | 136 | '*************************************** 137 | ' The cEngine class extends the ftEngine class to override the On... methods 138 | Class cEngine Extends ftEngine 139 | '------------------------------------------ 140 | 'Callback method which is called when a layer is updated. 141 | Method OnLayerUpdate:Int(layer:ftLayer) 142 | '_g.guiTextfield.SetText("FPS: "+_g.fE.GetFPS()) 143 | Return 0 144 | End 145 | End 146 | 147 | '*************************************** 148 | Function Main:Int() 149 | ' Create an instance of the cGame class and store it inside the global var 'g' 150 | _g = New cGame 151 | 152 | Return 0 153 | End 154 | 155 | -------------------------------------------------------------------------------- /examples/Input/KeyMapping/KeyMapping.monkey: -------------------------------------------------------------------------------- 1 | Strict 2 | 3 | #rem 4 | Script: KeyMapping.monkey 5 | Description: Sample script that shows how to use the ftKeyMapping class 6 | Author: Michael Hartlef 7 | Version: 1.02 8 | #End 9 | 10 | ' Import the fantomEngine framework which imports mojo itself 11 | Import fantomEngine 12 | 13 | ' The _g variable holds an instance to the cGame class 14 | Global _g:cGame 15 | 16 | '*************************************** 17 | ' The cGame class controls the app 18 | Class cGame Extends App 19 | ' Create a field to store the instance of the cEngine class, which is an instance 20 | ' of the ftEngine class itself 21 | Field fE:cEngine 22 | 23 | ' Create a field for the instance of the key mapping class 24 | Field cKeyMap:ftKeyMapping 25 | 26 | ' Create an object to be controlled by keys 27 | Field oCircle:ftObject 28 | 29 | '------------------------------------------ 30 | Method OnCreate:Int() 31 | ' Set the update rate of Mojo's OnUpdate to 60 FPS. 32 | SetUpdateRate(60) 33 | 34 | ' Create an instance of the fantomEngine, which was created via the cEngine class 35 | fE = New cEngine 36 | 37 | ' Create an instance of the key mapping class 38 | cKeyMap = New ftKeyMapping 39 | 40 | ' Create the map string so instead of pressing A/D/W/S to move the circle, you can press the cursor keys 41 | Local mapStr:String = KEY_A + ";" + KEY_LEFT + "~n" + KEY_D + ";" + KEY_RIGHT + "~n" + KEY_W + ";" + KEY_UP + "~n" + KEY_S + ";" + KEY_DOWN 42 | 43 | ' Load key mapping class from a string 44 | cKeyMap.LoadFromString(mapStr) 45 | 46 | ' Create a circle and store the object so we can control it 47 | oCircle = fE.CreateCircle(20,320,240) 48 | 49 | ' Print some info text into the console 50 | Print ("Instead of pressing A/D/W/S to move the circle, you can press the cursor keys to control the circle.") 51 | Return 0 52 | End 53 | '------------------------------------------ 54 | Method OnUpdate:Int() 55 | ' Exit the app if the ESCAPE key was hit 56 | If KeyHit( KEY_ESCAPE ) Then fE.ExitApp() 57 | 58 | ' Move the circle corresponding to the key presses 59 | If KeyDown( cKeyMap.GetKey(KEY_A) ) 60 | oCircle.SetPos(-2,0,True) 61 | Endif 62 | If KeyDown( cKeyMap.GetKey(KEY_D) ) 63 | oCircle.SetPos( 2,0,True) 64 | Endif 65 | If KeyDown( cKeyMap.GetKey(KEY_W) ) 66 | oCircle.SetPos(0,-2,True) 67 | Endif 68 | If KeyDown( cKeyMap.GetKey(KEY_S) ) 69 | oCircle.SetPos(0,2,True) 70 | Endif 71 | 72 | ' Determine the delta time and the update factor for the engine 73 | Local d:Float = Float(fE.CalcDeltaTime())/60.0 74 | 75 | ' Update all objects of the engine 76 | If fE.GetPaused() = False Then 77 | fE.Update(d) 78 | Endif 79 | Return 0 80 | End 81 | '------------------------------------------ 82 | Method OnRender:Int() 83 | ' Check if the engine is not paused 84 | If fE.GetPaused() = False Then 85 | ' Clear the screen 86 | Cls 87 | 88 | ' Render all visible objects of the engine 89 | fE.Render() 90 | Endif 91 | Return 0 92 | End 93 | '------------------------------------------ 94 | Method OnResume:Int() 95 | ' Set the pause flag of the engine to FALSE so objects, timers and transitions are updated again 96 | fE.SetPaused(False) 97 | 98 | Return 0 99 | End 100 | '------------------------------------------ 101 | Method OnSuspend:Int() 102 | ' Set the pause flag of the engine to TRUE so objects, timers and transitions are paused (not updated) 103 | fE.SetPaused(True) 104 | 105 | Return 0 106 | End 107 | End 108 | 109 | '*************************************** 110 | ' The cEngine class extends the ftEngine class to override the On... methods 111 | Class cEngine Extends ftEngine 112 | ' No On.. callback methods are used in this example 113 | End 114 | 115 | '*************************************** 116 | Function Main:Int() 117 | ' Create an instance of the cGame class and store it inside the global var 'g' 118 | _g = New cGame 119 | 120 | Return 0 121 | End 122 | -------------------------------------------------------------------------------- /examples/Input/SwipeDetection/SwipeDetection.data/compass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Input/SwipeDetection/SwipeDetection.data/compass.png -------------------------------------------------------------------------------- /examples/Input/SwipeDetection/SwipeDetection.data/needle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Input/SwipeDetection/SwipeDetection.data/needle.png -------------------------------------------------------------------------------- /examples/Input/SwipeDetection/SwipeDetection.monkey: -------------------------------------------------------------------------------- 1 | Strict 2 | 3 | #rem 4 | Script: SwipeDetection.monkey 5 | Description: Example script on how To use ther swipe detection And its OnSwipeDone event 6 | Author: Michael Hartlef 7 | Version: 1.05 8 | #End 9 | 10 | ' Set the AutoSuspend functionality to TRUE so OnResume/OnSuspend are called 11 | #MOJO_AUTO_SUSPEND_ENABLED=True 12 | 13 | ' Import the fantomEngine framework which imports mojo itself 14 | Import fantomEngine 15 | 16 | ' The _g variable holds an instance to the cGame class 17 | Global _g:cGame 18 | 19 | '*************************************** 20 | ' The cGame class controls the app 21 | Class cGame Extends App 22 | ' Create a field to store the instance of the cEngine class, which is an instance 23 | ' of the ftEngine class itself 24 | Field fE:cEngine 25 | 26 | Field compass:ftObject 27 | Field needle:ftObject 28 | '------------------------------------------ 29 | Method OnCreate:Int() 30 | ' Set the update rate of Mojo's OnUpdate to 60 FPS. 31 | SetUpdateRate(60) 32 | 33 | ' Create an instance of the fantomEngine, which was created via the cEngine class 34 | fE = New cEngine 35 | 36 | 'Load the images of the needle and the compass 37 | compass = fE.CreateImage("compass.png", fE.GetCanvasWidth()/2, fE.GetCanvasHeight()/2) 38 | needle = fE.CreateImage("needle.png", fE.GetCanvasWidth()/2, fE.GetCanvasHeight()/2) 39 | 40 | 'Activate the swipe detection 41 | fE.ActivateSwipe(True) 42 | 43 | 'Set the dead distance to 50 pixel. Swipes are only detected if they have a length greater in pixel greater this 44 | fE.SetSwipeDeadDist(50) 45 | 46 | 'Set the swipe angle snapping to 45 degrees. This will snap the needle to 0,45,90,135,180,225,270 and 315 degrees 47 | fE.SetSwipeSnap(45) 48 | 'If you just wanna get 0,90,180,270 degrees, you would need to snap it to 90 degrees 49 | Return 0 50 | End 51 | '------------------------------------------ 52 | Method OnUpdate:Int() 53 | 'Get the current delta time and determine the speed factor for the next update call 54 | Local d:Float = Float(fE.CalcDeltaTime())/60.0 55 | 56 | 'Update the engine 57 | fE.Update(Float(d)) 58 | 59 | 'Update the swipe detection 60 | fE.SwipeUpdate(0) 61 | 62 | Return 0 63 | End 64 | '------------------------------------------ 65 | Method OnRender:Int() 66 | 'Clear the screen with a nice blue color 67 | Cls 0,0,255 68 | 69 | 'Render all objects of the engine 70 | fE.Render() 71 | 72 | 'Draw the current FramesPerSecond value 73 | DrawText("FPS:"+fE.GetFPS(),10,10) 74 | 75 | Return 0 76 | End 77 | End 78 | 79 | '*************************************** 80 | ' The cEngine class extends the ftEngine class to override the On... methods 81 | Class cEngine Extends ftEngine 82 | '------------------------------------------ 83 | 'This method is called when a swipe was detected. You will get the angle, the distance and the speed value with is the factor of distance/time. 84 | Method OnSwipeDone:Int(touchIndex:Int, sAngle:Float, sDist:Float, sSpeed:Float) 85 | Print ("Distance:" +Int(sDist)) 86 | 'Calculate the angle difference between the swipe and the needle 87 | Local angleDiff:Float = sAngle - _g.needle.GetAngle() 88 | 89 | 'Determine which direction the needle has to turn 90 | If angleDiff > 180.0 Then angleDiff = angleDiff -360.0 91 | If angleDiff < -180.0 Then angleDiff = angleDiff +360.0 92 | 93 | 'Cancel the current transition of the needle, if there is one 94 | _g.needle.CancelTransAll() 95 | 96 | 'Start a new rotation transition 97 | _g.needle.CreateTransRot(angleDiff, 500*Abs(angleDiff/45), True, 0 ) 98 | 99 | Return 0 100 | End 101 | End 102 | 103 | '*************************************** 104 | Function Main:Int() 105 | ' Create an instance of the cGame class and store it inside the global var 'g' 106 | _g = New cGame 107 | Return 0 108 | End 109 | -------------------------------------------------------------------------------- /examples/Localization/Localization.data/font.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Localization/Localization.data/font.png -------------------------------------------------------------------------------- /examples/Localization/Localization.data/translation.txt: -------------------------------------------------------------------------------- 1 | Play%;%DE%:%Spielen%;%JP%:%遊ぶ 2 | Options%;%DE%:%Optionen%;%JP%:%オプション 3 | Help%;%DE%:%Hilfe%;%JP%:%手伝う 4 | Buy%;%DE%:%Kaufen%;%JP%:%買う 5 | MultiLine%;%DE%:%Diese Zeile%LF%erscheint in zwei Zeilen 6 | Score%;%DE%:%Punkte%;%EN%:%Score%;%FR%:%Score 7 | Back%;%DE%:%Zurück%;%EN%:%Back%;%FR%:%Retour 8 | Credits%;%DE%:%Credits%;%EN%:%Credits%;%FR%:%Credits 9 | GameOver%;%DE%:%Spielende%;%EN%:%Game Over%;%FR%:%Game Over 10 | Sound%;%DE%:%Töne%;%EN%:%Sound%;%FR%:%Son 11 | Music%;%DE%:%Musik%;%EN%:%Music;%FR%:%Musique 12 | Highscore%;%DE%:%Rangliste%;%EN%:%Highscorelist%;%FR%:%Highscore 13 | ShotsFired%;%DE%:%Schüsse abgefeuert%;%EN%:%Shots fired%;%FR%:%Missiles tirés 14 | BombsHit%;%DE%:%Bomben getroffen%;%EN%:%Bombs hit%;%FR%:%Bombes explosées 15 | Hitrate%;%DE%:%Trefferquote%;%EN%:%Hitrate%;%FR%:%% de réussite 16 | NewHighscore%;%DE%:%Neuer Highscore%;%EN%:%New Highscore%;%FR%:%Nouveau Highscore 17 | BonusActive%;%DE%:%Bonus aktiv%;%EN%:%Bonus active%;%FR%:%Bonus activé 18 | BonusDeactivated%;%DE%:%Bonus deaktiviert%;%EN%:%Bonus deactivated%;%FR%:%Bonus desactivé 19 | Level%;%DE%:%Level%;%EN%:%Level%;%FR%:%Niveau 20 | Reached%;%DE%:%erreicht%;%EN%:%reached%;%FR%:%--- 21 | Loading%;%DE%:%Laden%;%EN%:%Loading%;%FR%:%Chargement 22 | TouchScreen%;%DE%:%Berühre den Bildschirm%;%EN%:%Touch the screen to go back%;%FR%:%Toucher l'écran pour retourner en arrière 23 | HowtoPlay%;%DE%:%Anleitung%;%EN%:%How to play%;%FR%:%Comment jouer 24 | MultiLine%;%DE%:%Dieser Text%LF%erscheint in zwei Zeilen%;%EN%:%This text%LF%appears in two lines 25 | HowtoPlayText%;%EN%:%Defend your cities against the waves of deadly bombs. Try to destroy the bombs with your rockets.%LF%To fire a rocket, simply touch the screen at the location you want to fire it. But be aware, that you don't have endless energy and watch your energy level closely.%LF%Be quick when the bonus symbol appears and shoot it too. It will help you big time!%;%FR%:%Défendez votre ville des attaques, en détruisant les bombes avec vos missiles.%LF%Pour envoyer un missile, touchez l'écran à l'endroit où vous voulez qu'il explose. Mais attention, votre énergie est limitée, surveillez votre niveau.%LF%Soyez rapide quand les bonus apparaissent pour les toucher, ils vous seront bien utiles! -------------------------------------------------------------------------------- /examples/Localization/Localization.monkey: -------------------------------------------------------------------------------- 1 | Strict 2 | 3 | #rem 4 | Script: Localization.monkey 5 | Description: Sample script that shows how to use the ftLocalization class 6 | Author: Michael Hartlef 7 | Version: 1.03 8 | #End 9 | 10 | ' Import the fantomEngine framework which imports mojo itself 11 | Import fantomEngine 12 | 13 | ' The _g variable holds an instance to the cGame class 14 | Global _g:cGame 15 | 16 | '*************************************** 17 | ' The cGame class controls the app 18 | Class cGame Extends App 19 | ' Create a field to store the instance of the cEngine class, which is an instance 20 | ' of the ftEngine class itself 21 | Field fE:cEngine 22 | 23 | ' Create a field for the instance of the localization class 24 | Field cTrans:ftLocalization 25 | 26 | '------------------------------------------ 27 | Method OnCreate:Int() 28 | ' Set the update rate of Mojo's OnUpdate to 60 FPS. 29 | SetUpdateRate(60) 30 | 31 | ' Create an instance of the fantomEngine, which was created via the cEngine class 32 | fE = New cEngine 33 | 34 | ' Create an instance of the localization class 35 | cTrans = New ftLocalization 36 | 37 | ' Load the text file with the translationslocalization class from a string 38 | Local locStr:String = LoadString("translation.txt") 39 | 40 | ' Load localization class from a string 41 | ' Local locStr:String = "Play;DE:Spielen~nOptions;DE:Optionen" 42 | cTrans.LoadFromString(locStr) 43 | 44 | ' Load a font to create some text 45 | Local font1 := fE.LoadFont("font") 46 | 47 | ' Now create two text objects with the translated text 48 | fE.CreateText(font1, "Play means " + cTrans.GetString("Play","DE") + " in german.", 5, 20) 49 | fE.CreateText(font1, "Play means " + cTrans.GetString("Play","JP") + " in japanese.", 5, 60) 50 | fE.CreateText(font1, "Options means " + cTrans.GetString("Options","DE") + " in german.", 5, 100) 51 | 52 | fE.CreateText(font1, cTrans.GetString("MultiLine","DE"), 5, 200) 53 | 54 | Return 0 55 | End 56 | '------------------------------------------ 57 | Method OnUpdate:Int() 58 | If KeyHit( KEY_CLOSE ) fE.ExitApp() 59 | ' Determine the delta time and the update factor for the engine 60 | Local d:Float = Float(fE.CalcDeltaTime())/60.0 61 | 62 | ' Update all objects of the engine 63 | If fE.GetPaused() = False Then 64 | fE.Update(d) 65 | Endif 66 | Return 0 67 | End 68 | '------------------------------------------ 69 | Method OnRender:Int() 70 | ' Check if the engine is not paused 71 | If fE.GetPaused() = False Then 72 | ' Clear the screen 73 | Cls 74 | 75 | ' Render all visible objects of the engine 76 | fE.Render() 77 | Endif 78 | Return 0 79 | End 80 | '------------------------------------------ 81 | Method OnResume:Int() 82 | ' Set the pause flag of the engine to FALSE so objects, timers and transitions are updated again 83 | fE.SetPaused(False) 84 | 85 | Return 0 86 | End 87 | '------------------------------------------ 88 | Method OnSuspend:Int() 89 | ' Set the pause flag of the engine to TRUE so objects, timers and transitions are paused (not updated) 90 | fE.SetPaused(True) 91 | 92 | Return 0 93 | End 94 | End 95 | 96 | '*************************************** 97 | ' The cEngine class extends the ftEngine class to override the On... methods 98 | Class cEngine Extends ftEngine 99 | ' No On.. callback methods are used in this example 100 | End 101 | 102 | '*************************************** 103 | Function Main:Int() 104 | ' Create an instance of the cGame class and store it inside the global var 'g' 105 | _g = New cGame 106 | 107 | Return 0 108 | End 109 | -------------------------------------------------------------------------------- /examples/Misc/MultiClass/MultiClass.monkey: -------------------------------------------------------------------------------- 1 | Strict 2 | 3 | #rem 4 | Script: MultiClass.monkey 5 | Description: This sample script shows how to split your project into several classes and files 6 | Author: Michael Hartlef 7 | Version: 1.02 8 | #End 9 | 10 | ' Set the AutoSuspend functionality to TRUE so OnResume/OnSuspend are called 11 | #MOJO_AUTO_SUSPEND_ENABLED=True 12 | 13 | ' Import the fantomEngine framework which imports mojo itself 14 | Import fantomEngine 15 | Import gameClass 16 | Import engineClass 17 | Import setupClass 18 | Import customObjClass 19 | 20 | ' The _g variable holds an instance to the cGame class 21 | Global _g:cGame 22 | 23 | 24 | '*************************************** 25 | Function Main:Int() 26 | ' Create an instance of the cGame class and store it inside the global var 'g' 27 | _g = New cGame 28 | 29 | Return 0 30 | End 31 | 32 | -------------------------------------------------------------------------------- /examples/Misc/MultiClass/customObjClass.monkey: -------------------------------------------------------------------------------- 1 | Strict 2 | 3 | ' Import the main file 4 | Import MultiClass 5 | 6 | '*************************************** 7 | ' The cSetup class takes care of setting up some objects during its creation 8 | Class cCustomObj Extends ftObject 9 | Field myfield:Int = 0 10 | '------------------------------------------ 11 | Method New() 12 | ' Set some properties during the creation of the object 13 | Self.SetWrapScreen(True) 14 | Self.SetSpeed(10,-45) 15 | Self.SetColor(255,0,0) 16 | Self.SetID(888) 17 | End 18 | '------------------------------------------ 19 | ' Overwrite the ftObject.Render method 20 | Method Render:Void(xoff:Float=0.0, yoff:Float=0.0) 21 | ' Call the super class render method which takes care of alpha, color and blendmode changes automatically for us 22 | ' Attention, childs of this object will be drawn first if you do it this way. 23 | Super.Render(xoff, yoff) 24 | 25 | ' Now render the object ourself 26 | PushMatrix 27 | Translate ((xPos+xoff), (yPos+yoff)) 28 | Rotate 360.0-angle 29 | Scale (Self.scaleX, Self.scaleY) 30 | DrawCircle -Self.w * (Self.handleX-0.5), -Self.h * (Self.handleY-0.5), Self.radius 31 | mojo.SetColor(255,255,0) 32 | mojo.SetAlpha(1.0) 33 | DrawRect -5, -h*Self.handleY, 10, h 34 | 35 | ' As we have changed mojo's color and alpha settings, we need to restore them from the engines internal stored values, 36 | ' so the next obejct will be rendered correctly. 37 | Self.engine.RestoreColor() 38 | Self.engine.RestoreAlpha() 39 | 40 | PopMatrix 41 | 42 | End 43 | '------------------------------------------ 44 | ' Overwrite the ftObject.Update method of the ftObject so we can call the local CustOnObjectUpdate method. 45 | Method Update:Void(delta:Float=1.0) 46 | Super.Update(delta) 47 | ' Now get the current alpha and lower its value 48 | Local alpha:= Self.GetAlpha() 49 | alpha -= 0.02 50 | If alpha < 0.0 Then alpha = 1.0 51 | Self.SetAlpha(alpha) 52 | End 53 | '------------------------------------------ 54 | ' Now we create a custom method of this object. 55 | Method customRotate:Void(angle:Float) 56 | Self.SetAngle(angle, True) 57 | End 58 | End 59 | -------------------------------------------------------------------------------- /examples/Misc/MultiClass/engineClass.monkey: -------------------------------------------------------------------------------- 1 | Strict 2 | 3 | ' Import the main file 4 | Import MultiClass 5 | 6 | '*************************************** 7 | ' The cEngine class extends the ftEngine class to override the On... methods 8 | Class cEngine Extends ftEngine 9 | '------------------------------------------ 10 | Method OnLayerTransition:Int(transId:Int, layer:ftLayer) 11 | ' This method is called when a layer finishes its transition 12 | Return 0 13 | End 14 | '------------------------------------------ 15 | Method OnLayerUpdate:Int(layer:ftLayer) 16 | ' This method is called when a layer finishes its update 17 | Return 0 18 | End 19 | '------------------------------------------ 20 | Method OnObjectCollision:Int(obj:ftObject, obj2:ftObject) 21 | ' This method is called when an object collided with another object 22 | Return 0 23 | End 24 | '------------------------------------------ 25 | Method OnObjectDelete:Int(obj:ftObject) 26 | ' This method is called when an object is removed. You need to activate the event via ftObject.ActivateDeleteEvent. 27 | Return 0 28 | End 29 | '------------------------------------------ 30 | Method OnObjectRender:Int(obj:ftObject) 31 | ' This method is called when an object was being rendered. You need to activate the event via ftObject.ActivateRenderEvent. 32 | Return 0 33 | End 34 | '------------------------------------------ 35 | Method OnObjectSort:Int(obj1:ftObject, obj2:ftObject) 36 | ' This method is called when objects are compared during a sort of its layer list 37 | Return 0 38 | End 39 | '------------------------------------------ 40 | Method OnObjectTimer:Int(timerId:Int, obj:ftObject) 41 | ' This method is called when an objects' timer was being fired. 42 | Return 0 43 | End 44 | '------------------------------------------ 45 | Method OnObjectTouch:Int(obj:ftObject, touchId:Int) 46 | ' This method is called when an object was touched 47 | Return 0 48 | End 49 | '------------------------------------------ 50 | Method OnObjectTransition:Int(transId:Int, obj:ftObject) 51 | ' This method is called when an object finishes its transition and the transition has an ID > 0. 52 | Return 0 53 | End 54 | '------------------------------------------ 55 | Method OnObjectUpdate:Int(obj:ftObject) 56 | ' This method is called when an object finishes its update. You can deactivate the event via ftObject.ActivateUpdateEvent. 57 | If obj.GetID()=888 Then 58 | cCustomObj(obj).customRotate(5) 59 | Endif 60 | Return 0 61 | End 62 | '------------------------------------------ 63 | Method OnMarkerBounce:Int(marker:ftMarker, obj:ftObject) 64 | ' This method is called, when a path marker reaches the end of the path and is about to bounce backwards. 65 | Return 0 66 | End 67 | '------------------------------------------ 68 | Method OnMarkerCircle:Int(marker:ftMarker, obj:ftObject) 69 | ' This method is called, when a path marker reaches the end of the path and is about to do another circle. 70 | Return 0 71 | End 72 | '------------------------------------------ 73 | Method OnMarkerStop:Int(marker:ftMarker, obj:ftObject) 74 | ' This method is called, when a path marker reaches the end of the path and stops there. 75 | Return 0 76 | End 77 | '------------------------------------------ 78 | Method OnMarkerWarp:Int(marker:ftMarker, obj:ftObject) 79 | ' This method is called, when a path marker reaches the end of the path and is about to warp to the start to go on. 80 | Return 0 81 | End 82 | '------------------------------------------ 83 | Method OnMarkerWP:Int(marker:ftMarker, obj:ftObject) 84 | ' This method is called, when a path marker reaches a waypoint of its path. 85 | Return 0 86 | End 87 | '------------------------------------------ 88 | Method OnSwipeDone:Int(touchIndex:Int, sAngle:Float, sDist:Float, sSpeed:Float) 89 | ' This method is called when a swipe gesture was detected 90 | Return 0 91 | End 92 | '------------------------------------------ 93 | Method OnTimer:Int(timerId:Int) 94 | ' This method is called when an engine timer was being fired. 95 | Return 0 96 | End 97 | End 98 | -------------------------------------------------------------------------------- /examples/Misc/MultiClass/gameClass.monkey: -------------------------------------------------------------------------------- 1 | Strict 2 | 3 | ' Import the main file 4 | Import MultiClass 5 | 6 | '*************************************** 7 | ' The cGame class controls the app 8 | Class cGame Extends App 9 | ' Create a field to store the instance of the cEngine class, which is an instance 10 | ' of the ftEngine class itself 11 | Field fE:cEngine 12 | 13 | ' Add two fields that will hold the canvas size 14 | Field cW:Float 15 | Field cH:Float 16 | 17 | '------------------------------------------ 18 | Method OnCreate:Int() 19 | ' Set the update rate of Mojo's OnUpdate to 60 FPS. 20 | SetUpdateRate(60) 21 | 22 | ' Create an instance of the fantomEngine, which was created via the cEngine class 23 | fE = New cEngine 24 | 25 | ' Set the virtual canvas size to 800x600 26 | fE.SetCanvasSize(800,600) 27 | 28 | ' Now store the size of the canvas into some fields so you can access it in the over classes easily 29 | cW = fE.GetCanvasWidth() 30 | cH = fE.GetCanvasHeight() 31 | 32 | ' Now setup some objects. For this we create in instance of another class that takes care of that. 33 | New cSetup 34 | 35 | Return 0 36 | End 37 | '------------------------------------------ 38 | Method OnUpdate:Int() 39 | ' If the CLOSE key was hit, exit the app ... needed for GLFW and Android I think. 40 | If KeyHit( KEY_CLOSE ) Then fE.ExitApp() 41 | 42 | ' Determine the delta time and the update factor for the engine 43 | Local timeDelta:Float = Float(fE.CalcDeltaTime())/60.0 44 | 45 | ' Update all objects of the engine 46 | If fE.GetPaused() = False Then 47 | fE.Update(timeDelta) 48 | Endif 49 | Return 0 50 | End 51 | '------------------------------------------ 52 | Method OnRender:Int() 53 | ' Check if the engine is not paused 54 | If fE.GetPaused() = False Then 55 | ' Clear the screen 56 | Cls 0,0,0 57 | 58 | ' Render all visible objects of the engine 59 | fE.Render() 60 | Endif 61 | Return 0 62 | End 63 | '------------------------------------------ 64 | Method OnResume:Int() 65 | ' Set the pause flag of the engine to FALSE so objects, timers and transitions are updated again 66 | fE.SetPaused(False) 67 | 68 | Return 0 69 | End 70 | '------------------------------------------ 71 | Method OnSuspend:Int() 72 | ' Set the pause flag of the engine to TRUE so objects, timers and transitions are paused (not updated) 73 | fE.SetPaused(True) 74 | 75 | Return 0 76 | End 77 | End 78 | 79 | 80 | -------------------------------------------------------------------------------- /examples/Misc/MultiClass/setupClass.monkey: -------------------------------------------------------------------------------- 1 | Strict 2 | 3 | ' Import the main file 4 | Import MultiClass 5 | 6 | '*************************************** 7 | ' The cSetup class takes care of setting up some objects during its creation 8 | Class cSetup 9 | Field eng:ftEngine 10 | '------------------------------------------ 11 | 'We only need one method for this class 12 | Method New() 13 | ' Let's store the engine instance inside a local class field so it is easier to access 14 | eng = _g.fE 15 | 16 | ' Now we create a normal ftObject and set some properties 17 | Local circle := eng.CreateCircle(30, _g.cW/2.0, _g.cH/2.0) 18 | circle.SetWrapScreen(True) 19 | circle.SetSpeed(5,45) 20 | circle.SetColor(0,255,0) 21 | 22 | ' Next we create a custom object. Its definition is made inside the customObjClass.monkey file 23 | Local custCircle :cCustomObj = cCustomObj(eng.CreateCircle(30, _g.cW/2.0, _g.cH/2.0, New cCustomObj)) 24 | ' Give this object a type that is not take care of in its regular Render method as we draw it ourselfs 25 | custCircle.type = 9999 26 | custCircle.myfield = 7777 27 | 28 | 29 | 30 | ' Now we create a normal ftObject and set some properties 31 | Local circle2 := eng.CreateCircle(20, _g.cW/2.0, _g.cH/2.0) 32 | circle2.SetWrapScreen(True) 33 | circle2.SetSpeed(5,145) 34 | circle2.SetColor(255,0,0) 35 | End 36 | End 37 | -------------------------------------------------------------------------------- /examples/Misc/UpdateObjects/UpdateObjects.monkey: -------------------------------------------------------------------------------- 1 | Strict 2 | 3 | #rem 4 | Script: UpdateObjects.monkey 5 | Description: Sample script to show how to update objects based on their category 6 | Author: Michael Hartlef 7 | Version: 1.02 8 | #End 9 | 10 | ' Set the AutoSuspend functionality to TRUE so OnResume/OnSuspend are called 11 | #MOJO_AUTO_SUSPEND_ENABLED=True 12 | 13 | ' Import the fantomEngine framework which imports mojo itself 14 | Import fantomEngine 15 | 16 | ' The _g variable holds an instance to the cGame class 17 | Global _g:cGame 18 | 19 | '*************************************** 20 | ' The cGame class controls the app 21 | Class cGame Extends App 22 | ' Create a field to store the instance of the cEngine class, which is an instance 23 | ' of the ftEngine class itself 24 | Field fE:cEngine 25 | 26 | ' Define a constant for a timer 27 | Const engineTimer:Int = 1 28 | 29 | ' Define 2 constants to identify each type of object 30 | Const ENEMY:Int = 100 31 | Const FRIEND:Int = 101 32 | 33 | '------------------------------------------ 34 | Method SpawnObject:Void() 35 | ' Create a simple circle 36 | Local tmpObj := fE.CreateCircle(20,fE.GetCanvasWidth()-20,Rnd(20,fE.GetCanvasHeight()-20)) 37 | ' Give it a random speed facing left 38 | tmpObj.SetSpeed(Rnd(5,10),270) 39 | ' Give it a random size 40 | tmpObj.SetScale(Rnd(0.2,1.0)) 41 | ' Now create a timer to spawn the next object 42 | fE.CreateTimer(engineTimer, Rnd(200,1000)) 43 | 44 | ' Tag the object with a 50% chance to be a FRIEND or an ENEMY, and give it a color. 45 | If Rnd(10)>5 46 | tmpObj.SetTag(ENEMY) 47 | Else 48 | tmpObj.SetTag(FRIEND) 49 | tmpObj.SetColor(255,0,255) 50 | Endif 51 | End 52 | '------------------------------------------ 53 | Method OnCreate:Int() 54 | ' Set the update rate of Mojo's OnUpdate to 60 FPS. 55 | SetUpdateRate(60) 56 | 57 | ' Create an instance of the fantomEngine, which was created via the cEngine class 58 | fE = New cEngine 59 | 60 | ' Create a timer without a connection to an object which creates new circles at every second 61 | fE.CreateTimer(engineTimer, 500) 62 | 63 | ' Create tweo lines to mark where each object type will be removed 64 | fE.CreateLine(20,0,20,fE.GetCanvasHeight()) 65 | fE.CreateLine(200,0,200,fE.GetCanvasHeight()) 66 | 67 | Return 0 68 | End 69 | '------------------------------------------ 70 | Method OnUpdate:Int() 71 | ' If the CLOSE key was hit, exit the app ... needed for GLFW and Android I think. 72 | If KeyHit( KEY_CLOSE ) Then fE.ExitApp() 73 | 74 | ' Determine the delta time and the update factor for the engine 75 | Local timeDelta:Float = Float(fE.CalcDeltaTime())/60.0 76 | 77 | ' Update all objects of the engine 78 | If fE.GetPaused() = False Then 79 | fE.Update(timeDelta) 80 | Endif 81 | Return 0 82 | End 83 | '------------------------------------------ 84 | Method OnRender:Int() 85 | ' Check if the engine is not paused 86 | If fE.GetPaused() = False Then 87 | ' Clear the screen 88 | Cls 0,255,0 89 | 90 | ' Render all visible objects of the engine 91 | fE.Render() 92 | ' Draw some debugging info on the screen 93 | SetColor(255,255,0) 94 | DrawText("FPS: "+ fE.GetFPS(), 20,20) 95 | DrawText("ObjCount: "+ fE.GetObjCount(), 20,40) 96 | ' Restore the current color of the engine 97 | fE.RestoreColor() 98 | Endif 99 | Return 0 100 | End 101 | End 102 | 103 | '*************************************** 104 | ' The cEngine class extends the ftEngine class to override the On... methods 105 | Class cEngine Extends ftEngine 106 | Method OnObjectUpdate:Int(obj:ftObject) 107 | ' This method is called when an object finishes its update. You can deactivate the event via ftObject.ActivateUpdateEvent. 108 | 109 | ' Remove the enemy object depending on its tag and X-Position 110 | If obj.GetTag()=_g.ENEMY And obj.GetPosX() < 20 111 | obj.Remove() 112 | Endif 113 | ' Remove the friend object depending on its tag and X-Position 114 | If obj.GetTag()=_g.FRIEND And obj.GetPosX() < 200 115 | obj.Remove() 116 | Endif 117 | Return 0 118 | End 119 | '------------------------------------------ 120 | Method OnTimer:Int(timerId:Int) 121 | ' This method is called when an engine timer was being fired. 122 | If timerId = _g.engineTimer 123 | _g.SpawnObject() 124 | Endif 125 | Return 0 126 | End 127 | End 128 | 129 | '*************************************** 130 | Function Main:Int() 131 | ' Create an instance of the cGame class and store it inside the global var 'g' 132 | _g = New cGame 133 | 134 | Return 0 135 | End 136 | 137 | -------------------------------------------------------------------------------- /examples/Objects/Appearance/BlendMode/BlendMode.data/particle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Objects/Appearance/BlendMode/BlendMode.data/particle.png -------------------------------------------------------------------------------- /examples/Objects/Appearance/BlendMode/BlendMode.monkey: -------------------------------------------------------------------------------- 1 | Strict 2 | 3 | #rem 4 | Script: BlendMode.monkey 5 | Description: Sample script that shows how To use the blend mode 6 | Author: Michael Hartlef 7 | Version: 1.02 8 | #End 9 | 10 | ' Import the fantomEngine framework which imports mojo itself 11 | Import fantomEngine 12 | 13 | ' The _g variable holds an instance to the cGame class 14 | Global _g:cGame 15 | 16 | '*************************************** 17 | ' The cGame class controls the app 18 | Class cGame Extends App 19 | ' Create a field to store the instance of the cEngine class, which is an instance 20 | ' of the ftEngine class itself 21 | Field fE:cEngine 22 | 23 | Field p:ftObject 24 | Field p2:ftObject 25 | 26 | '------------------------------------------ 27 | Method OnCreate:Int() 28 | ' Set the update rate of Mojo's OnUpdate to 60 FPS. 29 | SetUpdateRate(60) 30 | 31 | ' Create an instance of the fantomEngine, which was created via the cEngine class 32 | fE = New cEngine 33 | 34 | ' Create one particle below the squares 35 | p=fE.CreateImage("particle.png",320,240) 36 | 37 | 'Create 4 squares with different colors, alpha values and blendmodes. 38 | Local obj0:=fE.CreateBox(200,200,220,140) 39 | obj0.SetColor(0,0,255) 40 | 41 | Local obj1:=fE.CreateBox(200,200,220,340) 42 | obj1.SetColor(0,255,0) 43 | obj1.SetBlendMode(mojo.AdditiveBlend) 44 | 45 | Local obj3:=fE.CreateBox(200,200,420,140) 46 | obj3.SetColor(255,0,0) 47 | obj3.SetAlpha(0.8) 48 | 49 | Local obj4:=fE.CreateBox(200,200,420,340) 50 | obj4.SetColor(0,255,255) 51 | obj4.SetBlendMode(mojo.AdditiveBlend) 52 | obj4.SetAlpha(0.8) 53 | 54 | ' Create one particle above the squares 55 | p2=fE.CreateImage("particle.png",320,240) 56 | 57 | Return 0 58 | End 59 | '------------------------------------------ 60 | Method OnUpdate:Int() 61 | ' Determine the delta time and the update factor for the engine 62 | Local d:Float = Float(fE.CalcDeltaTime())/60.0 63 | 64 | p.SetPos(MouseX()-50, MouseY()-50) 65 | p2.SetPos(MouseX()+50, MouseY()+50) 66 | 67 | ' Update all objects of the engine 68 | fE.Update(d) 69 | 70 | ' Switch the blendmodes of the particles when you hit the space bar 71 | If KeyHit(KEY_SPACE) Then 72 | Print ("BlendMode(p) set to "+(1-p.GetBlendMode())) 73 | Print ("BlendMode(p2) set to "+(1-p2.GetBlendMode())) 74 | p.SetBlendMode(1-p.GetBlendMode()) 75 | p2.SetBlendMode(1-p2.GetBlendMode()) 76 | Endif 77 | Return 0 78 | End 79 | '------------------------------------------ 80 | Method OnRender:Int() 81 | ' Clear the screen 82 | Cls 83 | 84 | ' Render all visible objects of the engine 85 | fE.Render() 86 | Return 0 87 | End 88 | End 89 | 90 | '*************************************** 91 | ' The cEngine class extends the ftEngine class to override the On... methods 92 | Class cEngine Extends ftEngine 93 | ' No On.. callback methods are used in this example 94 | End 95 | 96 | '*************************************** 97 | Function Main:Int() 98 | _g = New cGame 99 | Return 0 100 | End 101 | -------------------------------------------------------------------------------- /examples/Objects/Appearance/FlashObject/FlashObject2.data/font.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Objects/Appearance/FlashObject/FlashObject2.data/font.png -------------------------------------------------------------------------------- /examples/Objects/Behaviour/ObjectMovement/ObjectMovement.monkey: -------------------------------------------------------------------------------- 1 | Strict 2 | 3 | #Rem 4 | Script: ObjectMovement.monkey 5 | Description: Sample script that shows how to control your objects at runtime 6 | Author: Michael Hartlef 7 | Version: 1.04 8 | #End 9 | 10 | ' Import the fantomEngine framework which imports mojo itself 11 | Import fantomEngine 12 | 13 | ' The _g variable holds an instance to the cGame class 14 | Global _g:cGame 15 | 16 | '*************************************** 17 | ' The cGame class controls the app 18 | Class cGame Extends App 19 | ' Create a field to store the instance of the cEngine class, which is an instance 20 | ' of the ftEngine class itself 21 | Field fE:cEngine 22 | 23 | ' Create a field to store the canon object so we can handle it directly 24 | Field canon:ftObject 25 | 26 | ' Create two fields that store the width and height of the canvas 27 | Field cw:Float 28 | Field ch:Float 29 | 30 | Field once:Bool = False 31 | 32 | '------------------------------------------ 33 | ' The SpawnShot method will create a new shot. It sets its ID , positions it 34 | ' infront of the canon and set its speed and heading reagrding the angle of the 35 | ' canon. 36 | Method SpawnShot:Int() 37 | ' Determine the current angle of the canon 38 | Local curAngle:Float = canon.GetAngle() 39 | 40 | ' Determine the vector that is 50 pixels away infront of the canon 41 | Local pos:Float[] = canon.GetVector(50,curAngle) 42 | 43 | ' Create a shot in the middle of the screen 44 | Local shot:ftObject = fE.CreateCircle(5,pos[0], pos[1]) 45 | 46 | ' Set the speed and the angle of the shot 47 | shot.SetSpeed(-10, curAngle) 48 | 49 | ' Set a random color for the shot 50 | shot.SetColor(Rnd(255),Rnd(255),Rnd(255)) 51 | 52 | ' Set its ID to 222 so we can detect it during the OnObjectUdpate event 53 | shot.SetID(222) 54 | 55 | once = false 56 | Return 0 57 | End 58 | '------------------------------------------ 59 | Method OnCreate:Int() 60 | ' Set the update rate of Mojo's OnUpdate events to be determined by the devices refresh rate. 61 | SetUpdateRate(0) 62 | 63 | ' Create an instance of the fantomEngine, which was created via the cEngine class 64 | fE = New cEngine 65 | 66 | ' Determine and store the width and height of the canvas 67 | cw = fE.GetCanvasWidth() 68 | ch = fE.GetCanvasHeight() 69 | 70 | ' Create the canon in the middle of the screen 71 | canon = fE.CreateBox(20,60, cw/2, ch/2 ) 72 | 73 | ' Color the canon blue 74 | canon.SetColor(0,0,255) 75 | 76 | ' Set the ID of the canon so it won't be detected as a shot later 77 | canon.SetID(111) 78 | Return 0 79 | End 80 | '------------------------------------------ 81 | Method OnUpdate:Int() 82 | ' Determine the delta time and the update factor for the engine 83 | Local d:Float = Float(fE.CalcDeltaTime())/60.0 84 | 85 | ' Update all objects of the engine 86 | fE.Update(d) 87 | 88 | ' If the LEFT key was pressed, turn the canon by 2 degrees left 89 | If KeyDown(KEY_LEFT) Then canon.SetAngle(-2,True) 90 | 91 | ' If the RIGHT key was pressed, turn the canon by 2 degrees right 92 | If KeyDown(KEY_RIGHT) Then canon.SetAngle(2,True) 93 | 94 | ' If the SPACE key was pressed, spwan a new shot 95 | If KeyHit(KEY_SPACE) Then SpawnShot() 96 | 97 | Return 0 98 | End 99 | '------------------------------------------ 100 | Method OnRender:Int() 101 | ' Clear the screen 102 | Cls 103 | 104 | ' Render all visible objects of the engine 105 | fE.Render() 106 | 107 | Return 0 108 | End 109 | End 110 | 111 | '*************************************** 112 | ' The cEngine class extends the ftEngine class to override the On... methods 113 | Class cEngine Extends ftEngine 114 | Method OnObjectUpdate:Int(obj:ftObject) 115 | ' Determine if the object is a shot 116 | If obj.GetID() = 222 Then 117 | 118 | ' If the shot, reaches the top or bottom, set its speed to zero 119 | If obj.GetPosY() < 40 Or obj.GetPosY() > (_g.ch-40) Then obj.SetSpeed(0) 120 | 121 | ' If the shot reaches the left or right border, remove the object 122 | If obj.GetPosX() < 40 Or obj.GetPosX() > (_g.cw-40) Then obj.Remove() 123 | 124 | ' Slowly fade out the object 125 | 'obj.SetAlpha(obj.GetAlpha()-0.01) 126 | 127 | If _g.once = False And obj.GetSpeed() <> 0.0 Then 128 | _g.once = True 129 | Print("angle:"+obj.GetSpeedAngle()+" speed:"+obj.GetSpeed()+" objcount:"+_g.fE.GetObjCount()) 130 | Endif 131 | 132 | Endif 133 | Return 0 134 | End 135 | End 136 | 137 | '*************************************** 138 | Function Main:Int() 139 | ' Create an instance of the cGame class and store it inside the global var 'g' 140 | _g = New cGame 141 | Return 0 142 | End 143 | -------------------------------------------------------------------------------- /examples/Objects/Behaviour/ObjectMovement/ObjectMovement2.monkey: -------------------------------------------------------------------------------- 1 | Strict 2 | 3 | #Rem 4 | Script: ObjectMovement2.monkey 5 | Description: Sample script that shows how to control your objects at runtime 6 | Author: Michael Hartlef 7 | Version: 1.03 8 | #End 9 | 10 | ' Import the fantomEngine framework which imports mojo itself 11 | Import fantomEngine 12 | 13 | ' The _g variable holds an instance to the cGame class 14 | Global _g:cGame 15 | 16 | '*************************************** 17 | ' The cGame class controls the app 18 | Class cGame Extends App 19 | ' Create a field to store the instance of the cEngine class, which is an instance 20 | ' of the ftEngine class itself 21 | Field fE:cEngine 22 | 23 | ' Create a list to store the shots in 24 | Field shotList := New List 25 | 26 | ' Create two fields that store the width and height of the canvas 27 | Field cw:Float 28 | Field ch:Float 29 | 30 | '------------------------------------------ 31 | ' The SpawnShot method will create a new shot. It sets its ID , positions it 32 | ' infront of the canon and set its speed and heading reagrding the angle of the 33 | ' canon. 34 | Method SpawnShot:Int() 35 | ' Create a shot in the middle of the screen 36 | Local shot:ftObject = fE.CreateCircle(5,cw/2, ch/2) 37 | 38 | ' Set the tag of a shot 39 | shot.SetTag(Int(Rnd(1,5))) 40 | 41 | ' Set the speed and the angle of the shot 42 | shotList.AddLast(shot) 43 | 44 | Return 0 45 | End 46 | '------------------------------------------ 47 | Method OnCreate:Int() 48 | ' Set the update rate of Mojo's OnUpdate to 60 FPS. 49 | SetUpdateRate(60) 50 | 51 | ' Create an instance of the fantomEngine, which was created via the cEngine class 52 | fE = New cEngine 53 | 54 | ' Determine and store the width and height of the canvas 55 | cw = fE.GetCanvasWidth() 56 | ch = fE.GetCanvasHeight() 57 | 58 | ' Output some info 59 | Print ("Press SPACE to release a shot") 60 | 61 | Return 0 62 | End 63 | '------------------------------------------ 64 | Method OnUpdate:Int() 65 | ' Determine the delta time and the update factor for the engine 66 | Local d:Float = Float(fE.CalcDeltaTime())/60.0 67 | 68 | ' Update all shots depending on their tag value 69 | For Local obj := Eachin shotList 70 | If obj.GetTag() = 1 Then obj.SetPos(-2,0,True) 71 | If obj.GetTag() = 2 Then obj.SetPos(2,0,True) 72 | If obj.GetTag() = 3 Then obj.SetPos(0,-2,True) 73 | If obj.GetTag() = 4 Then obj.SetPos(0,2,True) 74 | Next 75 | 76 | ' Update all objects of the engine 77 | fE.Update(d) 78 | 79 | ' If the SPACE key was pressed, spwan a new shot 80 | If KeyHit(KEY_SPACE) Then SpawnShot() 81 | 82 | Return 0 83 | End 84 | '------------------------------------------ 85 | Method OnRender:Int() 86 | ' Clear the screen 87 | Cls 88 | 89 | ' Render all visible objects of the engine 90 | fE.Render() 91 | 92 | Return 0 93 | End 94 | End 95 | 96 | '*************************************** 97 | ' The cEngine class extends the ftEngine class to override the On... methods 98 | Class cEngine Extends ftEngine 99 | ' No On.. callback methods are used in this example 100 | End 101 | 102 | '*************************************** 103 | Function Main:Int() 104 | ' Create an instance of the cGame class and store it inside the global var 'g' 105 | _g = New cGame 106 | Return 0 107 | End 108 | -------------------------------------------------------------------------------- /examples/Objects/Creation/AnimObject/AnimObject.data/char_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Objects/Creation/AnimObject/AnimObject.data/char_01.png -------------------------------------------------------------------------------- /examples/Objects/Creation/AnimObject/AnimObject.data/char_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Objects/Creation/AnimObject/AnimObject.data/char_02.png -------------------------------------------------------------------------------- /examples/Objects/Creation/AnimObject/AnimObject.data/char_03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Objects/Creation/AnimObject/AnimObject.data/char_03.png -------------------------------------------------------------------------------- /examples/Objects/Creation/AnimObject/AnimObject.data/char_04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Objects/Creation/AnimObject/AnimObject.data/char_04.png -------------------------------------------------------------------------------- /examples/Objects/Creation/AnimObject/AnimObject.data/char_05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Objects/Creation/AnimObject/AnimObject.data/char_05.png -------------------------------------------------------------------------------- /examples/Objects/Creation/AnimObject/AnimObject.data/td_spritesheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Objects/Creation/AnimObject/AnimObject.data/td_spritesheet.png -------------------------------------------------------------------------------- /examples/Objects/Creation/AnimObject/AnimObject.data/td_spritesheet.txt: -------------------------------------------------------------------------------- 1 | td_spritesheet.png 2 | format: RGBA8888 3 | filter: Linear,Linear 4 | repeat: none 5 | TurretBase 6 | rotate: false 7 | xy: 0, 0 8 | size: 128, 128 9 | orig: 128, 128 10 | offset: 0, 0 11 | index: -1 12 | UFOShot 13 | rotate: false 14 | xy: 238, 34 15 | size: 8, 10 16 | orig: 8, 10 17 | offset: 1, 0 18 | index: -1 19 | Gold 20 | rotate: false 21 | xy: 206, 48 22 | size: 32, 32 23 | orig: 32, 32 24 | offset: 0, 0 25 | index: -1 26 | Destroyer 27 | rotate: false 28 | xy: 0, 128 29 | size: 128, 128 30 | orig: 128, 128 31 | offset: 0, 0 32 | index: -1 33 | TurretBullet 34 | rotate: false 35 | xy: 238, 16 36 | size: 18, 18 37 | orig: 18, 18 38 | offset: 55, 23 39 | index: -1 40 | Mine 41 | rotate: false 42 | xy: 160, 74 43 | size: 32, 32 44 | orig: 32, 32 45 | offset: 0, 0 46 | index: -1 47 | EkstraLive 48 | rotate: false 49 | xy: 128, 74 50 | size: 32, 32 51 | orig: 32, 32 52 | offset: 0, 0 53 | index: -1 54 | Silver 55 | rotate: false 56 | xy: 206, 16 57 | size: 32, 32 58 | orig: 32, 32 59 | offset: 0, 0 60 | index: -1 61 | TurretHead 62 | rotate: false 63 | xy: 128, 0 64 | size: 78, 74 65 | orig: 78, 74 66 | offset: 26, 30 67 | index: -1 68 | explosion 69 | rotate: false 70 | xy: 206, 0 71 | size: 48, 16 72 | orig: 48, 16 73 | offset: 0, 0 74 | index: -1 75 | -------------------------------------------------------------------------------- /examples/Objects/Creation/CopyObject/CopyObject.monkey: -------------------------------------------------------------------------------- 1 | Strict 2 | 3 | #Rem 4 | Script: CopyObject.monkey 5 | Description: Sample script that shows how To copy an Object with most of its parameters at runtime 6 | Author: Michael Hartlef 7 | Version: 1.04 8 | #End 9 | 10 | Import fantomEngine 11 | Global g:game 12 | 13 | '*************************************** 14 | Class game Extends App 15 | ' Create a field to store the instance of the engine class, which is an instance 16 | ' of the ftEngine class itself 17 | Field eng:engine 18 | 19 | ' Create two fields that store the width and height of the canvas 20 | Field cw:Float 21 | Field ch:Float 22 | 23 | '------------------------------------------ 24 | Method OnCreate:Int() 25 | ' Set the update rate of Mojo's OnUpdate to 60 FPS. 26 | SetUpdateRate(60) 27 | 28 | ' Create an instance of the fantomEngine, which was created via the engine class 29 | eng = New engine 30 | 31 | ' Determine and store the width and height of the canvas 32 | cw = eng.GetCanvasWidth() 33 | ch = eng.GetCanvasHeight() 34 | 35 | ' Create the 1st object in the middle of the screen 36 | Local obj1 := eng.CreateBox(20,20, cw/2, ch/2 ) 37 | 38 | ' Create a child object slightly in the middle of the screen and assign it to the 1st object 39 | Local childObj1 := eng.CreateBox(10,10, cw/2+40, ch/2+40 ) 40 | childObj1.SetParent(obj1) 41 | 42 | ' Copy the 1st object, which creates the 2nd object 43 | Local obj2 := eng.CopyObject(obj1) 44 | 45 | ' Set the speed and angle of the 1st object. The second object will stand still 46 | obj1.SetSpeed(10,Rnd(360)) 47 | 48 | ' Let the 2nd object spin and scale it up by a factor of 3 49 | obj2.SetSpin(10) 50 | obj2.SetScale(3) 51 | 52 | ' Let the 1st object wrap around the screen edges. 53 | obj1.SetWrapScreen(True) 54 | Return 0 55 | End 56 | '------------------------------------------ 57 | Method OnUpdate:Int() 58 | ' Determine the delta time and the update factor for the engine 59 | Local d:Float = Float(eng.CalcDeltaTime())/60.0 60 | 61 | ' Update all objects of the engine 62 | eng.Update(d) 63 | 64 | Return 0 65 | End 66 | '------------------------------------------ 67 | Method OnRender:Int() 68 | ' Clear the screen 69 | Cls 70 | 71 | ' Render all visible objects of the engine 72 | eng.Render() 73 | 74 | Return 0 75 | End 76 | End 77 | 78 | '*************************************** 79 | Class engine Extends ftEngine 80 | ' No On.. callback methods are used in this example 81 | End 82 | 83 | '*************************************** 84 | Function Main:Int() 85 | g = New game 86 | Return 0 87 | End 88 | -------------------------------------------------------------------------------- /examples/Objects/Creation/CustomObject/CustomObject.monkey: -------------------------------------------------------------------------------- 1 | Strict 2 | 3 | #rem 4 | Script: ExtendedObject.monkey 5 | Description: Sample script that shows how To extend the Object class 6 | Author: Michael Hartlef 7 | Version: 1.03 8 | #End 9 | 10 | ' Set the AutoSuspend functionality to TRUE so OnResume/OnSuspend are called 11 | #MOJO_AUTO_SUSPEND_ENABLED=True 12 | 13 | ' Import the fantomEngine framework which imports mojo itself 14 | Import fantomEngine 15 | 16 | ' The g variable holds an instance to the game class 17 | Global g:game 18 | 19 | 20 | '*************************************** 21 | ' This is the extended ftObject class 22 | Class myObject Extends ftObject 23 | Field mySpinSpeed:Float = -5.0 24 | Field xfactor:Float = 10.0 25 | '------------------------------------------ 26 | Method New() 27 | ' In its constructor, set the spin property to turn left 28 | Self.SetSpin(mySpinSpeed) 29 | 30 | ' Deactivate the OnObjectUpdate event call as 31 | ' we handle things inside the classes own Update method 32 | Self.ActivateUpdateEvent(False) 33 | End 34 | '------------------------------------------ 35 | Method Update:Void(speed:Float = 1.0) 36 | ' Call the Update method of the base class 37 | Super.Update(speed) 38 | 39 | ' Raise the objects scale factors 40 | Self.SetScale(0.01,True) 41 | End 42 | End 43 | 44 | '*************************************** 45 | ' The game class controls the app 46 | Class game Extends App 47 | ' Create a field to store the instance of the engine class, which is an instance 48 | ' of the ftEngine class itself 49 | Field eng:engine 50 | 51 | '------------------------------------------ 52 | Method OnCreate:Int() 53 | ' Set the update rate of Mojo's OnUpdate to 60 FPS. 54 | SetUpdateRate(60) 55 | 56 | ' Create an instance of the fantomEngine, which was created via the engine class 57 | eng = New engine 58 | 59 | ' Create a new box object on the right side with the base ftObject class 60 | Local obj := eng.CreateBox(20,120,eng.GetCanvasWidth()/4*3, eng.GetCanvasHeight()/2) 61 | 62 | ' Let the object spin by a factor of 10 at each Update call 63 | obj.SetSpin(10) 64 | 65 | ' Set its speed property to 2 66 | obj.SetSpeed(2) 67 | 68 | ' Now create another box object on the left side, but this 69 | ' time create the object within the method call an use the myObject class 70 | Local obj2 := eng.CreateBox(20,120,eng.GetCanvasWidth()/4, eng.GetCanvasHeight()/2, New myObject) 71 | 72 | ' Set its speed to -2 73 | obj2.SetSpeed(-2) 74 | 75 | Return 0 76 | End 77 | '------------------------------------------ 78 | Method OnUpdate:Int() 79 | ' Determine the delta time and the update factor for the engine 80 | Local d:Float = Float(eng.CalcDeltaTime())/60.0 81 | 82 | ' Update all objects of the engine 83 | eng.Update(d) 84 | 85 | Return 0 86 | End 87 | '------------------------------------------ 88 | Method OnRender:Int() 89 | ' Check if the app is not suspended 90 | If eng.GetPaused() = False Then 91 | ' Clear the screen 92 | Cls 93 | 94 | ' Render all visible objects of the engine 95 | eng.Render() 96 | Endif 97 | Return 0 98 | End 99 | '------------------------------------------ 100 | Method OnResume:Int() 101 | ' Set the pause flag of the engine to FALSE so objects, timers and transitions are updated again 102 | eng.SetPaused(false) 103 | Return 0 104 | End 105 | '------------------------------------------ 106 | Method OnSuspend:Int() 107 | ' Set the pause flag of the engine to TRUE so objects, timers and transitions are paused (not updated) 108 | eng.SetPaused(True) 109 | Return 0 110 | End 111 | End 112 | 113 | '*************************************** 114 | ' The engine class extends the ftEngine class to override the On... methods 115 | Class engine Extends ftEngine 116 | '------------------------------------------ 117 | Method OnObjectUpdate:Int(obj:ftObject) 118 | ' This method is called when an object finishes its update 119 | obj.SetPos(1,0,True) 120 | Return 0 121 | End 122 | End 123 | 124 | '*************************************** 125 | Function Main:Int() 126 | ' Create an instance of the game class and store it inside the global var 'g' 127 | g = New game 128 | 129 | Return 0 130 | End 131 | -------------------------------------------------------------------------------- /examples/Objects/Creation/LoadImage/LoadImage.data/cratesmall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Objects/Creation/LoadImage/LoadImage.data/cratesmall.png -------------------------------------------------------------------------------- /examples/Objects/Creation/LoadImage/LoadImage.monkey: -------------------------------------------------------------------------------- 1 | Strict 2 | 3 | #rem 4 | Script: LoadImage.monkey 5 | 'Description: Same script that shows how to load and a single image 6 | Author: Michael Hartlef 7 | Version: 1.01 8 | #End 9 | 10 | ' Set the AutoSuspend functionality to TRUE so OnResume/OnSuspend are called 11 | #MOJO_AUTO_SUSPEND_ENABLED=True 12 | 13 | ' Import the fantomEngine framework which imports mojo itself 14 | Import fantomEngine 15 | 16 | ' The _g variable holds an instance to the cGame class 17 | Global _g:cGame 18 | 19 | '*************************************** 20 | ' The cGame class controls the app 21 | Class cGame Extends App 22 | ' Create a field to store the instance of the cEngine class, which is an instance 23 | ' of the ftEngine class itself 24 | Field fE:cEngine 25 | 26 | 'Create a field for your object 27 | Field myObject:ftObject 28 | 29 | '------------------------------------------ 30 | Method OnCreate:Int() 31 | ' Set the update rate of Mojo's OnUpdate events to 60 FPS 32 | SetUpdateRate(60) 33 | 34 | ' Create an instance of the fantomEngine, which was created via the cEngine class 35 | fE = New cEngine 36 | 37 | ' Now load the single image 38 | myObject = fE.CreateImage("cratesmall.png", 320, 240) 39 | 40 | Return 0 41 | End 42 | '------------------------------------------ 43 | Method OnUpdate:Int() 44 | If KeyHit( KEY_CLOSE ) Then fE.ExitApp() 45 | ' Determine the delta time and the update factor for the engine 46 | Local timeDelta:Float = Float(fE.CalcDeltaTime())/60.0 47 | 48 | ' Update all objects of the engine 49 | If fE.GetPaused() = False Then 50 | fE.Update(timeDelta) 51 | Endif 52 | Return 0 53 | End 54 | '------------------------------------------ 55 | Method OnRender:Int() 56 | ' Check if the engine is not paused 57 | If fE.GetPaused() = False Then 58 | ' Clear the screen 59 | Cls 60 | 61 | ' Render all visible objects of the engine 62 | fE.Render() 63 | Endif 64 | Return 0 65 | End 66 | End 67 | 68 | '*************************************** 69 | ' The cEngine class extends the ftEngine class to override the On... methods 70 | Class cEngine Extends ftEngine 71 | '------------------------------------------ 72 | Method OnObjectUpdate:Int(obj:ftObject) 73 | ' This method is called when an object finishes its update. You can deactivate the event via ftObject.ActivateUpdateEvent. 74 | obj.SetAngle(1,True) 75 | Return 0 76 | End 77 | End 78 | 79 | '*************************************** 80 | Function Main:Int() 81 | ' Create an instance of the cGame class and store it inside the global var 'g' 82 | _g = New cGame 83 | 84 | Return 0 85 | End 86 | -------------------------------------------------------------------------------- /examples/Objects/Creation/RemoveObject/RemoveObject.data/cratesmall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Objects/Creation/RemoveObject/RemoveObject.data/cratesmall.png -------------------------------------------------------------------------------- /examples/Objects/Creation/RemoveObject/RemoveObject.monkey: -------------------------------------------------------------------------------- 1 | Strict 2 | 3 | #rem 4 | Script: RemoveObject.monkey 5 | Description: Sampe script that shows how to remove objects 6 | Author: Michael Hartlef 7 | Version: 1.04 8 | #End 9 | 10 | ' Set the AutoSuspend functionality to TRUE so OnResume/OnSuspend are called 11 | #MOJO_AUTO_SUSPEND_ENABLED=True 12 | 13 | ' Import the fantomEngine framework which imports mojo itself 14 | Import fantomEngine 15 | 16 | ' The g variable holds an instance to the game class 17 | Global g:game 18 | 19 | 20 | '*************************************** 21 | ' The game class controls the app 22 | Class game Extends App 23 | ' Create a field to store the instance of the engine class, which is an instance 24 | ' of the ftEngine class itself 25 | Field eng:engine 26 | 27 | Field delCount:Int = 0 28 | Field layerNo:Int =1 29 | Field layer2:ftLayer 30 | Field layer1:ftLayer 31 | 32 | '------------------------------------------ 33 | Method SpawnObjects:Void(anz:Int=100) 34 | If layerNo = 1 Then 35 | eng.SetDefaultLayer(layer1) 36 | layerNo = 2 37 | Else 38 | eng.SetDefaultLayer(layer2) 39 | layerNo = 1 40 | Endif 41 | For Local i:=1 To anz 42 | 'Local obj := eng.CreateCircle(10,Rnd(eng.GetCanvasWidth()), Rnd(eng.GetCanvasHeight())) 43 | Local obj := eng.CreateImage("cratesmall.png",Rnd(eng.GetCanvasWidth()), Rnd(eng.GetCanvasHeight())) 44 | For Local i:=1 To 3 45 | 'Local obj2 := eng.CreateCircle(5,Rnd(eng.GetCanvasWidth()), Rnd(eng.GetCanvasHeight())) 46 | Local obj2 := eng.CreateImage("cratesmall.png",Rnd(eng.GetCanvasWidth()), Rnd(eng.GetCanvasHeight())) 47 | obj2.SetParent(obj) 48 | obj2.SetScale(Rnd(0.5)+0.5) 49 | Next 50 | Next 51 | End 52 | '------------------------------------------ 53 | Method OnCreate:Int() 54 | ' Set the update rate of Mojo's OnUpdate to 60 FPS. 55 | SetUpdateRate(60) 56 | 57 | ' Create an instance of the fantomEngine, which was created via the engine class 58 | eng = New engine 59 | 60 | layer1 = eng.GetDefaultLayer() 61 | layer2 = eng.CreateLayer() 62 | 63 | SpawnObjects() 64 | Return 0 65 | End 66 | '------------------------------------------ 67 | Method OnUpdate:Int() 68 | ' Determine the delta time and the update factor for the engine 69 | Local d:Float = Float(eng.CalcDeltaTime())/60.0 70 | 71 | ' Check if the app is not suspended 72 | If eng.GetPaused() = False Then 73 | ' Update all objects of the engine 74 | delCount = 0 75 | eng.Update(d) 76 | SpawnObjects() 77 | Endif 78 | Return 0 79 | End 80 | '------------------------------------------ 81 | Method OnRender:Int() 82 | ' Check if the app is not suspended 83 | If eng.GetPaused() = False Then 84 | ' Clear the screen 85 | Cls 86 | 87 | ' Render all visible objects of the engine 88 | eng.Render() 89 | DrawText("objects1="+layer1.GetObjCount(),20,20) 90 | DrawText("objects2="+layer2.GetObjCount(),20,40) 91 | DrawText("FPS="+eng.GetFPS(),20,60) 92 | Endif 93 | Return 0 94 | End 95 | '------------------------------------------ 96 | Method OnResume:Int() 97 | ' Set the pause flag of the engine to FALSE so objects, timers and transitions are updated again 98 | eng.SetPaused(false) 99 | Return 0 100 | End 101 | '------------------------------------------ 102 | Method OnSuspend:Int() 103 | ' Set the pause flag of the engine to TRUE so objects, timers and transitions are paused (not updated) 104 | eng.SetPaused(True) 105 | Return 0 106 | End 107 | 108 | End 109 | 110 | '*************************************** 111 | ' The engine class extends the ftEngine class to override the On... methods 112 | Class engine Extends ftEngine 113 | '------------------------------------------ 114 | Method OnObjectUpdate:Int(obj:ftObject) 115 | ' This method is called when an object finishes its update 116 | g.delCount = g.delCount + 1 117 | If g.delCount < 10001 Then obj.Remove() 118 | 119 | Return 0 120 | End 121 | 122 | End 123 | 124 | '*************************************** 125 | Function Main:Int() 126 | ' Create an instance of the game class and store it inside the global var 'g' 127 | g = New game 128 | 129 | Return 0 130 | End 131 | -------------------------------------------------------------------------------- /examples/Objects/DataStorage/DataStorage.monkey: -------------------------------------------------------------------------------- 1 | Strict 2 | 3 | #Rem 4 | Script: DataStorage.monkey 5 | Description: Sample script that shows how to store any data inside an Object and use it at runtime 6 | Author: Michael Hartlef 7 | Version: 1.03 8 | #End 9 | 10 | Import fantomEngine 11 | Global g:game 12 | 13 | 14 | '*************************************** 15 | ' This class will store some user defined data fields for our shot objects. 16 | ' Here it is the x/y speed factors for each bullet 17 | Class shotData 18 | Field xSpeed:Float 19 | Field ySpeed:Float 20 | End 21 | 22 | 23 | '*************************************** 24 | Class game Extends App 25 | ' Create a field to store the instance of the engine class, which is an instance 26 | ' of the ftEngine class itself 27 | Field eng:engine 28 | 29 | ' Create a field to store the canon object so we can handle it directly 30 | Field canon:ftObject 31 | 32 | ' Create two fields that store the width and height of the canvas 33 | Field cw:Float 34 | Field ch:Float 35 | 36 | '------------------------------------------ 37 | ' The SpawnShot method will create a new shot. It sets its ID , positions it 38 | ' infront of the canon and set its speed and heading reagrding the angle of the 39 | ' canon. 40 | Method SpawnShot:Int() 41 | ' Determine the current angle of the canon 42 | Local curAngle:Float = canon.GetAngle() 43 | 44 | ' Determine the vector that is 50 pixels away infront of the canon 45 | Local pos:Float[] = canon.GetVector(50,curAngle) 46 | 47 | ' Create a shot in the middle of the screen 48 | Local shot:ftObject = eng.CreateCircle(5,pos[0], pos[1]) 49 | 50 | ' Create a new shotData object 51 | Local userData := New shotData 52 | 53 | ' store the speed values in the data object 54 | userData.xSpeed = (pos[0] - cw/2) / 10 55 | userData.ySpeed = (pos[1] - ch/2) / 10 56 | 57 | ' Set the data object of the shot object 58 | 'shot.SetDataObj(Object(userData)) 59 | shot.SetDataObj(userData) 60 | 61 | ' Set its ID to 222 so we can detect it during the OnObjectUpdate event 62 | shot.SetID(222) 63 | Return 0 64 | End 65 | '------------------------------------------ 66 | Method OnCreate:Int() 67 | ' Set the update rate of Mojo's OnUpdate to 60 FPS. 68 | SetUpdateRate(60) 69 | 70 | ' Create an instance of the fantomEngine, which was created via the engine class 71 | eng = New engine 72 | 73 | ' Determine and store the width and height of the canvas 74 | cw = eng.GetCanvasWidth() 75 | ch = eng.GetCanvasHeight() 76 | 77 | ' Create the canon in the middle of the screen 78 | canon = eng.CreateBox(20,60, cw/2, ch/2 ) 79 | 80 | ' Set the ID of the canon so it won't be detected as a shot later 81 | canon.SetID(111) 82 | Return 0 83 | End 84 | '------------------------------------------ 85 | Method OnUpdate:Int() 86 | ' Determine the delta time and the update factor for the engine 87 | Local d:Float = Float(eng.CalcDeltaTime())/60.0 88 | 89 | ' Update all objects of the engine 90 | eng.Update(d) 91 | 92 | ' If the LEFT key was pressed, turn the canon by 2 degrees left 93 | If KeyDown(KEY_LEFT) Then canon.SetAngle(-2,True) 94 | 95 | ' If the RIGHT key was pressed, turn the canon by 2 degrees right 96 | If KeyDown(KEY_RIGHT) Then canon.SetAngle(2,True) 97 | 98 | ' If the SPACE key was pressed, spwan a new shot 99 | If KeyHit(KEY_SPACE) Then SpawnShot() 100 | 101 | Return 0 102 | End 103 | '------------------------------------------ 104 | Method OnRender:Int() 105 | ' Clear the screen 106 | Cls 107 | 108 | ' Render all visible objects of the engine 109 | eng.Render() 110 | 111 | Return 0 112 | End 113 | End 114 | 115 | '*************************************** 116 | Class engine Extends ftEngine 117 | Method OnObjectUpdate:Int(obj:ftObject) 118 | ' Determine if the object is a shot 119 | If obj.GetID() = 222 Then 120 | 121 | ' Get the data object, which holds the speed factors for the shot. 122 | Local ud:shotData = shotData(obj.GetDataObj()) 123 | 124 | 'Set the position relatively via the speed factors 125 | obj.SetPos(ud.xSpeed, ud.ySpeed, True) 126 | Endif 127 | Return 0 128 | End 129 | End 130 | 131 | '*************************************** 132 | Function Main:Int() 133 | g = New game 134 | Return 0 135 | End 136 | -------------------------------------------------------------------------------- /examples/Objects/Hierachy/ParentChild/ParentChild.monkey: -------------------------------------------------------------------------------- 1 | Strict 2 | 3 | #rem 4 | Script: ParentChild.monkey 5 | Description: Sample script to show how to use parent/child relationships. 6 | Author: Michael Hartlef 7 | Version: 1.04 8 | #End 9 | 10 | ' Import the fantomEngine framework which imports mojo itself 11 | Import fantomEngine 12 | 13 | ' The g variable holds an instance to the game class 14 | Global g:game 15 | 16 | 17 | '*************************************** 18 | ' The game class controls the app 19 | Class game Extends App 20 | ' Create a field to store the instance of the engine class, which is an instance 21 | ' of the ftEngine class itself 22 | Field eng:engine 23 | 24 | ' Create a field field that hold the parent 25 | Field parent:ftObject = Null 26 | 27 | '------------------------------------------ 28 | Method SpawnChild:Void() 29 | ' Create the child, it's a box 30 | Local child := eng.CreateBox(20, 20, eng.GetCanvasWidth()*(Rnd(0.5)+0.25), eng.GetCanvasHeight()*(Rnd(0.5)+0.25)) 31 | 32 | ' Connect the child to the parent 33 | child.SetParent(parent) 34 | 35 | ' Set a random color for the child 36 | child.SetColor(Rnd(255), Rnd(255), Rnd(255)) 37 | End 38 | '------------------------------------------ 39 | Method OnCreate:Int() 40 | ' Set the update rate of Mojo's OnUpdate to 60 FPS. 41 | SetUpdateRate(60) 42 | 43 | ' Create an instance of the fantomEngine, which was created via the engine class 44 | eng = New engine 45 | 46 | ' Seed the random number generator 47 | Seed = Millisecs() 48 | 49 | ' Create the parent 50 | parent = eng.CreateBox(40,40,eng.GetCanvasWidth()/2,eng.GetCanvasHeight()/2) 51 | 52 | ' Create the child and set its parent 53 | SpawnChild() 54 | Return 0 55 | End 56 | '------------------------------------------ 57 | Method OnUpdate:Int() 58 | ' Determine the delta time and the update factor for the engine 59 | Local d:Float = Float(eng.CalcDeltaTime())/60.0 60 | Local child:ftObject = Null 61 | 62 | ' If the parent has children, get the first child 63 | If parent.GetChildCount()>0 Then 64 | child = parent.GetChild(1) 65 | Endif 66 | 67 | ' Set the parents position accordingly to the mouse coordinates 68 | parent.SetPos(eng.GetTouchX(), eng.GetTouchY()) 69 | 70 | ' If there is a child, check for the P-Key and disconnect it from the parent 71 | If child <> Null Then 72 | If KeyHit(KEY_P) Then 73 | If child.GetParent() <> Null Then 74 | child.SetParent(Null) 75 | Endif 76 | Endif 77 | Endif 78 | ' If the N-Key was hit, spawn another child 79 | If KeyHit(KEY_N) Then 80 | SpawnChild() 81 | Endif 82 | ' If the Q-Key was hit, scale the parent upwards 83 | If KeyDown(KEY_Q) Then 84 | parent.SetScale(0.02,True) 85 | Endif 86 | ' If the W-Key was hit, scale the parent downpwards 87 | If KeyDown(KEY_W) Then 88 | parent.SetScale(-0.02,True) 89 | Endif 90 | ' If left mouse button was pressed, rotate the parent 91 | If MouseDown(MOUSE_LEFT) 92 | parent.SetAngle(2,True) 93 | Endif 94 | ' If right mouse button was pressed, rotate the parent 95 | If MouseDown(MOUSE_RIGHT) 96 | parent.SetAngle(-2,True) 97 | Endif 98 | ' Update all objects of the engine 99 | eng.Update(d) 100 | Return 0 101 | End 102 | '------------------------------------------ 103 | Method OnRender:Int() 104 | ' Clear the screen 105 | Cls 106 | 107 | ' Render all visible objects of the engine 108 | eng.Render() 109 | Return 0 110 | End 111 | End 112 | 113 | '*************************************** 114 | ' The engine class extends the ftEngine class to override the On... methods 115 | Class engine Extends ftEngine 116 | ' No On.. callback methods are used in this example 117 | End 118 | 119 | '*************************************** 120 | Function Main:Int() 121 | ' Create an instance of the game class and store it inside the global var 'g' 122 | g = New game 123 | 124 | Return 0 125 | End 126 | -------------------------------------------------------------------------------- /examples/Objects/Hierachy/SortObjects/SortObjects.monkey: -------------------------------------------------------------------------------- 1 | Strict 2 | 3 | #rem 4 | Script: SortObjects.monkey 5 | Description: Sample script that shows how so sort objects inside a layer 6 | Author: Michael Hartlef 7 | Version: 1.04 8 | #End 9 | 10 | ' Set the AutoSuspend functionality to TRUE so OnResume/OnSuspend are called 11 | #MOJO_AUTO_SUSPEND_ENABLED=True 12 | 13 | ' Import the fantomEngine framework which imports mojo itself 14 | Import fantomEngine 15 | 16 | ' The g variable holds an instance to the game class 17 | Global g:game 18 | 19 | 20 | '*************************************** 21 | ' The game class controls the app 22 | Class game Extends App 23 | ' Create a field to store the instance of the engine class, which is an instance 24 | ' of the ftEngine class itself 25 | Field eng:engine 26 | 27 | ' Create a field for a new layer 28 | Field myLayer:ftLayer 29 | 30 | ' Create a field for a player controllable circle object 31 | Field myCircle:ftObject 32 | 33 | '------------------------------------------ 34 | Method OnCreate:Int() 35 | ' Set the update rate of Mojo's OnUpdate to 60 FPS. 36 | SetUpdateRate(60) 37 | 38 | ' Create an instance of the fantomEngine, which was created via the engine class 39 | eng = New engine 40 | 41 | ' Create the myLayer layer and set it as the default layer for new objects 42 | myLayer = eng.CreateLayer() 43 | eng.SetDefaultLayer(myLayer) 44 | 45 | ' Create a yellow circle that moves with the mouse cursor 46 | myCircle = eng.CreateCircle(30, eng.GetCanvasWidth()/2, eng.GetCanvasHeight()/2) 47 | myCircle.SetColor(255,255,0) 48 | 49 | ' Create a red box that doesn't move 50 | Local myBox := eng.CreateBox(130, 20, eng.GetCanvasWidth()/2, eng.GetCanvasHeight()/2) 51 | myBox.SetColor(255,0,0) 52 | 53 | 54 | Return 0 55 | End 56 | '------------------------------------------ 57 | Method OnUpdate:Int() 58 | ' Determine the delta time and the update factor for the engine 59 | Local d:Float = Float(eng.CalcDeltaTime())/60.0 60 | 61 | ' Check if the app is not suspended 62 | If eng.GetPaused() = False Then 63 | 64 | ' Move the circle to the mouse position 65 | myCircle.SetPos(eng.GetTouchX(), eng.GetTouchY()) 66 | 67 | ' Update all objects of the engine 68 | eng.Update(d) 69 | 70 | ' Sort all objects in the myLayer layer. 71 | myLayer.SortObjects() 72 | 73 | Endif 74 | Return 0 75 | End 76 | '------------------------------------------ 77 | Method OnRender:Int() 78 | ' Check if the app is not suspended 79 | If eng.GetPaused() = False Then 80 | ' Clear the screen 81 | Cls 82 | 83 | ' Render all visible objects of the engine 84 | eng.Render() 85 | Endif 86 | Return 0 87 | End 88 | '------------------------------------------ 89 | Method OnResume:Int() 90 | ' Set the pause flag of the engine to FALSE so objects, timers and transitions are updated again 91 | eng.SetPaused(false) 92 | Return 0 93 | End 94 | '------------------------------------------ 95 | Method OnSuspend:Int() 96 | ' Set the pause flag of the engine to TRUE so objects, timers and transitions are paused (not updated) 97 | eng.SetPaused(True) 98 | Return 0 99 | End 100 | 101 | End 102 | 103 | '*************************************** 104 | ' The engine class extends the ftEngine class to override the On... methods 105 | Class engine Extends ftEngine 106 | '------------------------------------------ 107 | Method OnObjectSort:Int(obj1:ftObject, obj2:ftObject) 108 | ' This method is called when objects are compared during a sort of its layer list 109 | 110 | ' We compare the bottom (yPos+Height/2) of each object, the ones with a smaller result will 111 | ' be sort infront of the other object and so appear behind the over object. 112 | If (obj1.yPos + obj1.GetHeight()/2) < (obj2.yPos + obj2.GetHeight()/2) Then 113 | Return False 114 | Else 115 | Return True 116 | Endif 117 | End 118 | End 119 | 120 | '*************************************** 121 | Function Main:Int() 122 | ' Create an instance of the game class and store it inside the global var 'g' 123 | g = New game 124 | 125 | Return 0 126 | End 127 | -------------------------------------------------------------------------------- /examples/Physics/Box2DIntegration/Box2DIntegration.data/cratesmall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Physics/Box2DIntegration/Box2DIntegration.data/cratesmall.png -------------------------------------------------------------------------------- /examples/Physics/JuggleSoccerBall/JuggleSoccerBall.data/ball.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Physics/JuggleSoccerBall/JuggleSoccerBall.data/ball.png -------------------------------------------------------------------------------- /examples/Physics/JuggleSoccerBall/JuggleSoccerBall.data/field.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Physics/JuggleSoccerBall/JuggleSoccerBall.data/field.png -------------------------------------------------------------------------------- /examples/Physics/MouseJoint/MouseJoint.data/cratesmall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Physics/MouseJoint/MouseJoint.data/cratesmall.png -------------------------------------------------------------------------------- /examples/Physics/Raycasting/Raycasting.data/ball.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Physics/Raycasting/Raycasting.data/ball.png -------------------------------------------------------------------------------- /examples/Physics/Raycasting/Raycasting.data/cratesmall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Physics/Raycasting/Raycasting.data/cratesmall.png -------------------------------------------------------------------------------- /examples/Physics/RevoluteJoint/RevoluteJoint.data/cratesmall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Physics/RevoluteJoint/RevoluteJoint.data/cratesmall.png -------------------------------------------------------------------------------- /examples/Scenes/SceneCreation/SceneCreation.data/font.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Scenes/SceneCreation/SceneCreation.data/font.png -------------------------------------------------------------------------------- /examples/Sound/Sound.data/happy.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Sound/Sound.data/happy.mp3 -------------------------------------------------------------------------------- /examples/Sound/Sound.data/shoot.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Sound/Sound.data/shoot.wav -------------------------------------------------------------------------------- /examples/SpriteSheets/SheetAnim/SheetAnim.data/spriteSheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/SpriteSheets/SheetAnim/SheetAnim.data/spriteSheet.png -------------------------------------------------------------------------------- /examples/SpriteSheets/SheetAnim/SheetAnim.data/spriteSheet.txt: -------------------------------------------------------------------------------- 1 | spriteSheet.png 2 | format: RGBA8888 3 | filter: Linear,Linear 4 | repeat: none 5 | Blinker 6 | rotate: false 7 | xy: 0, 0 8 | size: 128, 32 9 | orig: 128, 32 10 | offset: 0, 0 11 | index: -1 12 | Circle1 13 | rotate: false 14 | xy: 0, 32 15 | size: 32, 32 16 | orig: 32, 32 17 | offset: 1, 0 18 | index: -1 19 | Circle2 20 | rotate: false 21 | xy: 32, 32 22 | size: 32, 32 23 | orig: 32, 32 24 | offset: 1, 0 25 | index: -1 26 | Circle3 27 | rotate: false 28 | xy: 64, 32 29 | size: 32, 32 30 | orig: 32, 32 31 | offset: 1, 0 32 | index: -1 33 | Circle4 34 | rotate: false 35 | xy: 96, 32 36 | size: 32, 32 37 | orig: 32, 32 38 | offset: 1, 0 39 | index: -1 40 | Ship 41 | rotate: false 42 | xy: 0, 64 43 | size: 32, 32 44 | orig: 32, 32 45 | offset: 0, 0 46 | index: -1 47 | -------------------------------------------------------------------------------- /examples/SpriteSheets/TexturePacker/TexturePacker.data/td_spritesheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/SpriteSheets/TexturePacker/TexturePacker.data/td_spritesheet.png -------------------------------------------------------------------------------- /examples/SpriteSheets/TexturePacker/TexturePacker.data/td_spritesheet.txt: -------------------------------------------------------------------------------- 1 | td_spritesheet.png 2 | format: RGBA8888 3 | filter: Linear,Linear 4 | repeat: none 5 | TurretBase 6 | rotate: false 7 | xy: 0, 0 8 | size: 128, 128 9 | orig: 128, 128 10 | offset: 0, 0 11 | index: -1 12 | UFOShot 13 | rotate: false 14 | xy: 238, 34 15 | size: 8, 10 16 | orig: 8, 10 17 | offset: 1, 0 18 | index: -1 19 | Gold 20 | rotate: false 21 | xy: 206, 48 22 | size: 32, 32 23 | orig: 32, 32 24 | offset: 0, 0 25 | index: -1 26 | Destroyer 27 | rotate: false 28 | xy: 0, 128 29 | size: 128, 128 30 | orig: 128, 128 31 | offset: 0, 0 32 | index: -1 33 | TurretBullet 34 | rotate: false 35 | xy: 238, 16 36 | size: 18, 18 37 | orig: 18, 18 38 | offset: 55, 23 39 | index: -1 40 | Mine 41 | rotate: false 42 | xy: 160, 74 43 | size: 32, 32 44 | orig: 32, 32 45 | offset: 0, 0 46 | index: -1 47 | EkstraLive 48 | rotate: false 49 | xy: 128, 74 50 | size: 32, 32 51 | orig: 32, 32 52 | offset: 0, 0 53 | index: -1 54 | Silver 55 | rotate: false 56 | xy: 206, 16 57 | size: 32, 32 58 | orig: 32, 32 59 | offset: 0, 0 60 | index: -1 61 | TurretHead 62 | rotate: false 63 | xy: 128, 0 64 | size: 78, 74 65 | orig: 78, 74 66 | offset: 26, 30 67 | index: -1 68 | explosion 69 | rotate: false 70 | xy: 206, 0 71 | size: 48, 16 72 | orig: 48, 16 73 | offset: 0, 0 74 | index: -1 75 | -------------------------------------------------------------------------------- /examples/SpriteSheets/TexturePacker/TexturePacker.monkey: -------------------------------------------------------------------------------- 1 | Strict 2 | 3 | #rem 4 | Script: TexturePacker.monkey 5 | Description: Example script on how To use packed texture images created by the tool TexturePacker 6 | Author: Michael Hartlef 7 | Version: 1.05 8 | #end 9 | 10 | ' Set the AutoSuspend functionality to TRUE so OnResume/OnSuspend are called 11 | #MOJO_AUTO_SUSPEND_ENABLED=True 12 | 13 | ' Import the fantomEngine framework which imports mojo itself 14 | Import fantomEngine 15 | 16 | ' The g variable holds an instance to the game class 17 | Global g:game 18 | 19 | 20 | '*************************************** 21 | ' The game class controls the app 22 | Class game Extends App 23 | ' Create a field to store the instance of the engine class, which is an instance 24 | ' of the ftEngine class itself 25 | Field eng:engine 26 | 27 | '------------------------------------------ 28 | Method OnCreate:Int() 29 | ' Set the update rate of Mojo's OnUpdate to 60 FPS. 30 | SetUpdateRate(60) 31 | 32 | ' Create an instance of the fantomEngine, which was created via the engine class 33 | eng = New engine 34 | 35 | ' Set the virtual canvas size to 320x480 and the canvas scale mode to letter box 36 | eng.SetCanvasSize(320,480,ftEngine.cmLetterbox) 37 | 38 | ' Load the packed texture atlas 39 | Local tpatlas:Image = LoadImage("td_spritesheet.png") 40 | 41 | ' Load the packed texture atlas via ftSpriteAtlas class 42 | Local tpatlas2:ftSpriteAtlas = New ftSpriteAtlas 43 | tpatlas2.Load("td_spritesheet.png", "td_spritesheet.txt") 44 | 45 | ' Create several objects 46 | Local myObject0:ftObject = eng.CreateBox(eng.GetCanvasWidth(), eng.GetCanvasHeight(), eng.GetCanvasWidth()/2, eng.GetCanvasHeight()/2) 47 | myObject0.SetColor(0,0,155) 48 | 49 | Local myObject1:ftObject = eng.CreateImage(tpatlas, "td_spritesheet.txt", "gold", 0, 0) 50 | Local myObject2:ftObject = eng.CreateImage(tpatlas2.GetImage("gold"), eng.GetCanvasWidth(), 0) 51 | Local myObject3:ftObject = eng.CreateImage(tpatlas2.GetImage("gold"), 0, eng.GetCanvasHeight()) 52 | Local myObject4:ftObject = eng.CreateImage(tpatlas, "td_spritesheet.txt", "gold", eng.GetCanvasWidth(), eng.GetCanvasHeight()) 53 | 54 | Local myObject5:ftObject = eng.CreateImage(tpatlas, "td_spritesheet.txt", "turretbase", eng.GetCanvasWidth()/2, eng.GetCanvasHeight()/2) 55 | myObject5.SetSpin(1) 56 | 57 | Local myObject5b:ftObject = eng.CreateImage(tpatlas2.GetImage("turretbase"), eng.GetCanvasWidth()/2, eng.GetCanvasHeight()/2) 58 | 'Set the render area of an Object 59 | myObject5b.SetRenderArea(0,0,64,64) 60 | 'Set its color 61 | myObject5b.SetColor(205,50,205) 62 | 'Make it spin automatically 63 | myObject5b.SetSpin(-1) 64 | Return 0 65 | End 66 | '------------------------------------------ 67 | Method OnUpdate:Int() 68 | ' Determine the delta time and the update factor for the engine 69 | Local d:Float = Float(eng.CalcDeltaTime())/60.0 70 | 71 | ' Update all objects of the engine 72 | eng.Update(d) 73 | Return 0 74 | End 75 | '------------------------------------------ 76 | Method OnRender:Int() 77 | ' Check if the app is not suspended 78 | If eng.GetPaused() = False Then 79 | ' Clear the screen 80 | Cls 81 | 82 | ' Render all visible objects of the engine 83 | eng.Render() 84 | Endif 85 | Return 0 86 | End 87 | '------------------------------------------ 88 | Method OnResume:Int() 89 | ' Set the pause flag of the engine to FALSE so objects, timers and transitions are updated again 90 | eng.SetPaused(false) 91 | Return 0 92 | End 93 | '------------------------------------------ 94 | Method OnSuspend:Int() 95 | ' Set the pause flag of the engine to TRUE so objects, timers and transitions are paused (not updated) 96 | eng.SetPaused(True) 97 | Return 0 98 | End 99 | 100 | End 101 | 102 | '*************************************** 103 | ' The engine class extends the ftEngine class to override the On... methods 104 | Class engine Extends ftEngine 105 | ' No On.. callback methods are used in this example 106 | End 107 | 108 | '*************************************** 109 | Function Main:Int() 110 | g = New game 111 | Return 0 112 | End 113 | -------------------------------------------------------------------------------- /examples/Text/FontMachine/FontMachine.data/SportsFont_P_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Text/FontMachine/FontMachine.data/SportsFont_P_1.png -------------------------------------------------------------------------------- /examples/Text/FontMachine/FontMachine.data/SportsFont_P_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Text/FontMachine/FontMachine.data/SportsFont_P_2.png -------------------------------------------------------------------------------- /examples/Text/MultilineText/MultilineText.data/font.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Text/MultilineText/MultilineText.data/font.png -------------------------------------------------------------------------------- /examples/Text/MultilineText/MultilineText.monkey: -------------------------------------------------------------------------------- 1 | Strict 2 | 3 | #rem 4 | Script: MultilineText.monkey 5 | Description: Sample fantomEngine script, that shows how To use multiline text objects 6 | Author: Michael Hartlef 7 | Version: 1.02 8 | #End 9 | #MOJO_AUTO_SUSPEND_ENABLED=True 10 | Import fantomEngine 11 | Global g:game 12 | 13 | '*************************************** 14 | Class game Extends App 15 | ' Create a field to store the instance of the engine class, which is an instance 16 | ' of the ftEngine class itself 17 | Field eng:engine 18 | 19 | '------------------------------------------ 20 | Method OnCreate:Int() 21 | ' Set the update rate of Mojo's OnUpdate to 60 FPS. 22 | SetUpdateRate(60) 23 | 24 | ' Create an instance of the fantomEngine, which was created via the engine class 25 | eng = New engine 26 | 27 | ' Store the width and height of the canvas 28 | Local cw:Int = 1280 29 | Local ch:Int = 900 30 | 31 | ' Set virtual canvas size 32 | eng.SetCanvasSize(cw, ch) 33 | 34 | ' Load a bitmap font 35 | Local font:ftFont = eng.LoadFont("font.txt") 36 | 37 | ' Create to small boxes to define a cross hair 38 | Local b1:=eng.CreateBox(cw,3,cw/2,ch/2) 39 | Local b2:=eng.CreateBox(3,ch,cw/2,ch/2) 40 | 41 | ' Create some multi line text objects 42 | Local multitxt_TL:ftObject = eng.CreateText(font,"Hello World!~nMonkey is awesome~ntextAlignMode = taTopLeft",cw/2,ch/2, eng.taTopLeft) 43 | 'Local multitxt_CL:ftObject = eng.CreateText(font,"Hello World!~nMonkey is awesome~ntextAlignMode = taCenterLeft",cw/2,ch/2, eng.taCenterLeft) 44 | Local multitxt_BL:ftObject = eng.CreateText(font,"Hello World!~nMonkey is awesome~ntextAlignMode = taBottomLeft",cw/2,ch/2, eng.taBottomLeft) 45 | 46 | 'Local multitxt_TR:ftObject = eng.CreateText(font,"Hello World!~nMonkey is awesome~ntextAlignMode = taTopRight",cw/2,ch/2, eng.taTopRight) 47 | Local multitxt_CR:ftObject = eng.CreateText(font,"Hello World!~nMonkey is awesome~ntextAlignMode = taCenterRight",cw/2,ch/2, eng.taCenterRight) 48 | 'Local multitxt_BR:ftObject = eng.CreateText(font,"Hello World!~nMonkey is awesome~ntextAlignMode = taBottomRight",cw/2,ch/2, eng.taBottomRight) 49 | 50 | 'Local multitxt_TC:ftObject = eng.CreateText(font,"Hello World!~nMonkey is awesome~ntextAlignMode = taTopCenter",cw/2,ch/2, eng.taTopCenter) 51 | 'Local multitxt_CC:ftObject = eng.CreateText(font,"Hello World!~nMonkey is awesome~ntextAlignMode = taCenterCenter",cw/2,ch/2, eng.taCenterCenter) 52 | 'Local multitxt_BT:ftObject = eng.CreateText(font,"Hello World!~nMonkey is awesome~ntextAlignMode = taBottomCenter",cw/2,ch/2, eng.taBottomCenter) 53 | Return 0 54 | End 55 | '------------------------------------------ 56 | Method OnUpdate:Int() 57 | ' Determine the delta time and the update factor for the engine 58 | Local d:Float = Float(eng.CalcDeltaTime())/60.0 59 | 60 | ' Update all objects of the engine 61 | eng.Update(d) 62 | Return 0 63 | End 64 | '------------------------------------------ 65 | Method OnRender:Int() 66 | ' Clear the screen 67 | Cls 0,0,155 68 | 69 | ' Render all visible objects of the engine 70 | eng.Render() 71 | Return 0 72 | End 73 | '------------------------------------------ 74 | Method OnSuspend:Int() 75 | ' Clear the screen 76 | Error("xxx") 77 | Return 0 78 | End 79 | End 80 | 81 | '*************************************** 82 | Class engine Extends ftEngine 83 | ' No On.. callback methods are used in this example 84 | End 85 | 86 | 87 | '*************************************** 88 | Function Main:Int() 89 | g = New game 90 | Return 0 91 | End 92 | -------------------------------------------------------------------------------- /examples/TileMaps/DynamicMap/DynamicMap.data/tilesheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/TileMaps/DynamicMap/DynamicMap.data/tilesheet.png -------------------------------------------------------------------------------- /examples/TileMaps/DynamicMap/DynamicMap.monkey: -------------------------------------------------------------------------------- 1 | Strict 2 | 3 | #rem 4 | Script: DynamicMap.monkey 5 | Description: Example script on how to self build a (dynamic) map. 6 | Author: Michael Hartlef 7 | Version: 1.08 8 | #end 9 | 10 | ' Set the AutoSuspend functionality to TRUE so OnResume/OnSuspend are called 11 | #MOJO_AUTO_SUSPEND_ENABLED=True 12 | 13 | Import fantomEngine 14 | Global g:game 15 | 16 | 17 | '*************************************** 18 | Class game Extends App 19 | Field eng:engine 20 | Field tileMap:ftObject 21 | Field atlas:Image 22 | '------------------------------------------ 23 | Method OnCreate:Int() 24 | Local c:Int 25 | 26 | ' Set the update rate of Mojo's OnUpdate to 60 FPS. 27 | SetUpdateRate(60) 28 | 29 | 'Create an instance of the fantomEngine 30 | eng = New engine 31 | 32 | ' Set the canvas size of a usual Android canvas 33 | eng.SetCanvasSize(320,480) 34 | 35 | 'Define the tile size and how many tiles the map will have in each direction 36 | Local tileWidth:Int = 32 37 | Local tileHeight:Int = 32 38 | Local tileCountX:Int = 1000 39 | Local tileCountY:Int = 1000 40 | 41 | 42 | ' Load the sprite sheet that contains the tiles of our map. 43 | atlas = LoadImage("tilesheet.png" ) 44 | If atlas = Null Then Print ("atlas = null") 45 | 46 | ' Now create an empty tile map 47 | tileMap = eng.CreateTileMap(atlas, tileWidth, tileHeight, tileCountX , tileCountY, tileWidth/2.0, tileHeight/2.0 ) 48 | 49 | ' Next randomly build the map 50 | For Local yt:Int = 1 To tileCountY 51 | For local xt:Int = 1 To tileCountX 52 | tileMap.SetTileID(xt-1, yt-1, Rnd(0,15) ) 53 | Next 54 | Next 55 | 56 | ' Now add a text for the console 57 | Print "Use the cursor keys to move the map, and the mouse buttons to delete or randomly set a map tile." 58 | Return 0 59 | End 60 | '------------------------------------------ 61 | Method OnUpdate:Int() 62 | Local d:Float = Float(eng.CalcDeltaTime())/60.0 63 | If eng.GetPaused() = False Then 64 | 65 | eng.Update(Float(d)) 66 | 'Remove a tile when you click left with the mouse 67 | If MouseHit( MOUSE_LEFT ) Then 68 | tileMap.SetTileIDAt(eng.GetTouchX(),eng.GetTouchY(),-1) 69 | Endif 70 | 'Set a random tile 71 | If MouseHit( MOUSE_RIGHT ) Then 72 | tileMap.SetTileIDAt(eng.GetTouchX(),eng.GetTouchY(),Rnd(0,15)) 73 | Endif 74 | 'Move the camera with the cursor keys 75 | If KeyDown(KEY_LEFT) Then eng.SetCamX(-1,True) 76 | If KeyDown(KEY_RIGHT) Then eng.SetCamX(1,True) 77 | If KeyDown(KEY_UP) Then eng.SetCamY(-1,True) 78 | If KeyDown(KEY_DOWN) Then eng.SetCamY(1,True) 79 | Endif 80 | Return 0 81 | End 82 | '------------------------------------------ 83 | Method OnRender:Int() 84 | Local x:Int = eng.GetTouchX() 85 | Local y:Int = eng.GetTouchY() 86 | Cls 0,0,50 87 | eng.Render() 88 | 'Print some debugging messages like FPS and the tile ID under the mouse cursor 89 | DrawText("Tile unter mouse at "+x+":"+y+" = "+tileMap.GetTileIDAt(x,y),eng.GetLocalX(20, False),eng.GetLocalY(10, False)) 90 | DrawText("FPS:"+eng.GetFPS(),eng.GetLocalX(20, False),eng.GetLocalY(50, False)) 91 | Return 0 92 | End 93 | '------------------------------------------ 94 | Method OnResume:Int() 95 | eng.SetPaused(False) 96 | Return 0 97 | End 98 | '------------------------------------------ 99 | Method OnSuspend:Int() 100 | eng.SetPaused(True) 101 | Return 0 102 | End 103 | End 104 | 105 | '*************************************** 106 | Class engine Extends ftEngine 107 | ' No On.. callback methods are used in this example 108 | End 109 | 110 | '*************************************** 111 | Function Main:Int() 112 | g = New game 113 | Return 0 114 | End 115 | -------------------------------------------------------------------------------- /examples/TileMaps/EndlessMap/EndlessMap.monkey: -------------------------------------------------------------------------------- 1 | Strict 2 | 3 | #rem 4 | Script: endlessMap.monkey 5 | Description: Sample script that illustrates how to build an endless map 6 | Author: Michael Hartlef 7 | Version: 1.01 8 | #End 9 | 10 | ' Set the AutoSuspend functionality to TRUE so OnResume/OnSuspend are called 11 | #MOJO_AUTO_SUSPEND_ENABLED=True 12 | 13 | ' Import the fantomEngine framework which imports mojo itself 14 | Import fantomEngine 15 | 16 | ' The _g variable holds an instance to the cGame class 17 | Global _g:cGame 18 | 19 | '*************************************** 20 | ' The cTile class extends the ftObject class 21 | Class cTile Extends ftObject 22 | Field xTileOffset:Int 23 | '------------------------------------------ 24 | ' In this overwritten Udpqte method, the position of the tile 25 | ' will be updated and wrapped in relation to the mapPivot object. 26 | Method Update:Void(delta:Float=1.0) 27 | Self.SetPosX(Int(_g.mapPivot.GetPosX()+Self.xTileOffset)) 28 | If (Self.GetPosX()-Self.GetWidth()/2.0) > _g.fE.GetCanvasWidth() 29 | Self.SetPosX(-_g.fE.GetCanvasWidth() - Self.GetWidth(),True) 30 | Endif 31 | End 32 | End 33 | '*************************************** 34 | ' The cGame class controls the app 35 | Class cGame Extends App 36 | ' Create a field to store the instance of the cEngine class, which is an instance 37 | ' of the ftEngine class itself 38 | Field fE:cEngine 39 | 40 | ' We need a filed to store the mapPivot object 41 | Field mapPivot:ftObject 42 | '------------------------------------------ 43 | Method OnCreate:Int() 44 | ' Set the update rate of Mojo's OnUpdate to 60 FPS. 45 | SetUpdateRate(60) 46 | 47 | ' Create an instance of the fantomEngine, which was created via the cEngine class 48 | fE = New cEngine 49 | ' Set a virtual canvas size 50 | fE.SetCanvasSize(320,240) 51 | 52 | ' Now create some tiles that wil fill the screen. 53 | ' also store the X offset regarding the mapPivot object 54 | For Local y:= 0 To fE.GetCanvasHeight() Step 64 55 | For Local x:= 0 To fE.GetCanvasWidth() Step 64 56 | Local tile:=fE.CreateBox(64,64,x,y,New cTile) 57 | Local col:= Rnd(100,200) 58 | tile.SetColor(col,col,col) 59 | cTile(tile).xTileOffset = x 60 | Next 61 | Next 62 | 63 | ' Create the mapPivot object. You could create it before the tile objects, 64 | ' but because we want to display its position with a child object, it has to be 65 | ' created afterwards. 66 | mapPivot = fE.CreatePivot(0,0) 67 | mapPivot.SetSpeedX(3) 68 | 69 | ' Create a simple circle as a child of the mapPivot object. 70 | ' This will display the position of the MapPivot object. 71 | Local circle := fE.CreateCircle(20,0,0) 72 | circle.SetParent(mapPivot) 73 | 74 | Return 0 75 | End 76 | '------------------------------------------ 77 | Method OnUpdate:Int() 78 | ' If the CLOSE key was hit, exit the app ... needed for GLFW and Android I think. 79 | If KeyHit( KEY_CLOSE ) Then fE.ExitApp() 80 | 81 | ' Determine the delta time and the update factor for the engine 82 | Local timeDelta:Float = Float(fE.CalcDeltaTime())/60.0 83 | 84 | ' Update all objects of the engine 85 | If fE.GetPaused() = False Then 86 | fE.Update(timeDelta) 87 | Endif 88 | Return 0 89 | End 90 | '------------------------------------------ 91 | Method OnRender:Int() 92 | ' Check if the engine is not paused 93 | If fE.GetPaused() = False Then 94 | ' Clear the screen 95 | Cls 255,0,255 96 | 97 | ' Render all visible objects of the engine 98 | fE.Render() 99 | Endif 100 | Return 0 101 | End 102 | End 103 | 104 | '*************************************** 105 | ' The cEngine class extends the ftEngine class to override the On... methods 106 | Class cEngine Extends ftEngine 107 | '------------------------------------------ 108 | Method OnObjectUpdate:Int(obj:ftObject) 109 | ' Check if the mapPivot object left the screen and then wrap it back to the other side. 110 | ' Please note, that we don't use the buildin WrapScreen methods as we want to let it wrap 111 | ' outside the canvas. 112 | If obj = _g.mapPivot 113 | If (obj.GetPosX()-32) > Self.GetCanvasWidth() 114 | obj.SetPosX(-Self.GetCanvasWidth() - 64 ,True) 115 | Print ("privotWrap") 116 | Endif 117 | Endif 118 | Return 0 119 | End 120 | End 121 | 122 | '*************************************** 123 | Function Main:Int() 124 | ' Create an instance of the cGame class and store it inside the global var 'g' 125 | _g = New cGame 126 | 127 | Return 0 128 | End 129 | 130 | -------------------------------------------------------------------------------- /examples/TileMaps/Platformer/Platformer.data/platformer.json: -------------------------------------------------------------------------------- 1 | { "height":15, 2 | "layers":[ 3 | { 4 | "data":[2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1], 5 | "height":1, 6 | "name":"test", 7 | "opacity":1, 8 | "type":"tilelayer", 9 | "visible":true, 10 | "width":20, 11 | "x":0, 12 | "y":0 13 | }], 14 | "orientation":"orthogonal", 15 | "properties": 16 | { 17 | 18 | }, 19 | "tileheight":32, 20 | "tilesets":[ 21 | { 22 | "firstgid":1, 23 | "image":"tiles.png", 24 | "imageheight":128, 25 | "imagewidth":128, 26 | "margin":0, 27 | "name":"tiles.png", 28 | "properties": 29 | { 30 | 31 | }, 32 | "spacing":0, 33 | "tileheight":32, 34 | "tilewidth":32 35 | }], 36 | "tilewidth":32, 37 | "version":1, 38 | "width":20 39 | } -------------------------------------------------------------------------------- /examples/TileMaps/Platformer/Platformer.data/tiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/TileMaps/Platformer/Platformer.data/tiles.png -------------------------------------------------------------------------------- /examples/TileMaps/Platformer_Physics/Platformer_Physics.data/platformer.json: -------------------------------------------------------------------------------- 1 | { "height":15, 2 | "layers":[ 3 | { 4 | "data":[2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1], 5 | "height":1, 6 | "name":"test", 7 | "opacity":1, 8 | "type":"tilelayer", 9 | "visible":true, 10 | "width":20, 11 | "x":0, 12 | "y":0 13 | }], 14 | "orientation":"orthogonal", 15 | "properties": 16 | { 17 | 18 | }, 19 | "tileheight":32, 20 | "tilesets":[ 21 | { 22 | "firstgid":1, 23 | "image":"tiles.png", 24 | "imageheight":128, 25 | "imagewidth":128, 26 | "margin":0, 27 | "name":"tiles.png", 28 | "properties": 29 | { 30 | 31 | }, 32 | "spacing":0, 33 | "tileheight":32, 34 | "tilewidth":32 35 | }], 36 | "tilewidth":32, 37 | "version":1, 38 | "width":20 39 | } -------------------------------------------------------------------------------- /examples/TileMaps/Platformer_Physics/Platformer_Physics.data/platformer2.json: -------------------------------------------------------------------------------- 1 | { "height":15, 2 | "layers":[ 3 | { 4 | "data":[2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,1,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,1,2,2,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1], 5 | "height":1, 6 | "name":"test", 7 | "opacity":1, 8 | "type":"tilelayer", 9 | "visible":true, 10 | "width":20, 11 | "x":0, 12 | "y":0 13 | }], 14 | "orientation":"orthogonal", 15 | "properties": 16 | { 17 | 18 | }, 19 | "tileheight":32, 20 | "tilesets":[ 21 | { 22 | "firstgid":1, 23 | "image":"tiles.png", 24 | "imageheight":128, 25 | "imagewidth":128, 26 | "margin":0, 27 | "name":"tiles.png", 28 | "properties": 29 | { 30 | 31 | }, 32 | "spacing":0, 33 | "tileheight":32, 34 | "tilewidth":32 35 | }], 36 | "tilewidth":32, 37 | "version":1, 38 | "width":20 39 | } -------------------------------------------------------------------------------- /examples/TileMaps/Platformer_Physics/Platformer_Physics.data/tiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/TileMaps/Platformer_Physics/Platformer_Physics.data/tiles.png -------------------------------------------------------------------------------- /examples/TileMaps/Tiled/MultitileSets.data/font.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/TileMaps/Tiled/MultitileSets.data/font.png -------------------------------------------------------------------------------- /examples/TileMaps/Tiled/MultitileSets.data/maps/isometric_64x64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/TileMaps/Tiled/MultitileSets.data/maps/isometric_64x64.png -------------------------------------------------------------------------------- /examples/TileMaps/Tiled/MultitileSets.data/maps/tiles1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/TileMaps/Tiled/MultitileSets.data/maps/tiles1.png -------------------------------------------------------------------------------- /examples/TileMaps/Tiled/MultitileSets.data/maps/tiles2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/TileMaps/Tiled/MultitileSets.data/maps/tiles2.png -------------------------------------------------------------------------------- /examples/TileMaps/Tiled/Tiled.data/font.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/TileMaps/Tiled/Tiled.data/font.png -------------------------------------------------------------------------------- /examples/TileMaps/Tiled/Tiled.data/maps/sewer_tileset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/TileMaps/Tiled/Tiled.data/maps/sewer_tileset.png -------------------------------------------------------------------------------- /examples/TileMaps/Tiled/Tiled.data/maps/tmw_desert_spacing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/TileMaps/Tiled/Tiled.data/maps/tmw_desert_spacing.png -------------------------------------------------------------------------------- /examples/TileMaps/Tiled/TiledIsometric.data/font.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/TileMaps/Tiled/TiledIsometric.data/font.png -------------------------------------------------------------------------------- /examples/TileMaps/Tiled/TiledIsometric.data/maps/isometric_grass_and_water.json: -------------------------------------------------------------------------------- 1 | { "height":25, 2 | "layers":[ 3 | { 4 | "data":[24, 24, 23, 11, 19, 19, 12, 23, 24, 24, 23, 7, 2, 2, 1, 4, 2, 2, 3, 4, 4, 1, 3, 4, 1, 24, 23, 23, 14, 3, 3, 8, 12, 24, 24, 18, 4, 1, 3, 1, 3, 3, 4, 4, 1, 3, 1, 4, 3, 4, 11, 15, 15, 7, 1, 4, 3, 20, 23, 11, 7, 2, 1, 3, 1, 3, 4, 4, 3, 2, 2, 3, 4, 2, 1, 18, 4, 3, 2, 2, 4, 3, 8, 12, 18, 2, 4, 4, 3, 3, 1, 4, 2, 1, 4, 4, 4, 1, 1, 1, 14, 2, 1, 4, 2, 1, 4, 2, 8, 7, 5, 17, 6, 3, 3, 3, 4, 3, 4, 4, 3, 2, 4, 3, 4, 10, 6, 2, 1, 4, 4, 1, 3, 4, 3, 8, 12, 10, 6, 2, 1, 1, 1, 1, 2, 1, 4, 2, 1, 1, 24, 18, 1, 2, 4, 3, 3, 5, 6, 5, 13, 9, 11, 7, 3, 4, 1, 3, 1, 3, 4, 2, 4, 4, 4, 24, 14, 4, 2, 5, 6, 2, 8, 22, 9, 23, 24, 10, 6, 2, 1, 3, 1, 5, 6, 2, 3, 4, 4, 2, 19, 7, 3, 1, 8, 7, 4, 1, 8, 12, 24, 23, 23, 10, 17, 6, 3, 1, 8, 7, 1, 3, 3, 3, 1, 1, 2, 4, 2, 2, 3, 3, 4, 3, 20, 24, 23, 23, 23, 23, 18, 2, 2, 3, 1, 4, 4, 1, 1, 1, 3, 3, 5, 13, 6, 1, 2, 2, 5, 9, 23, 23, 24, 23, 24, 14, 1, 3, 1, 1, 3, 3, 4, 4, 4, 2, 4, 16, 24, 10, 6, 2, 4, 20, 23, 23, 24, 23, 23, 24, 14, 2, 4, 2, 4, 5, 6, 4, 3, 1, 3, 1, 20, 23, 24, 10, 6, 3, 8, 12, 24, 23, 23, 23, 24, 14, 1, 2, 1, 5, 9, 18, 4, 3, 4, 4, 2, 8, 12, 23, 24, 18, 4, 3, 16, 24, 24, 24, 23, 24, 18, 1, 3, 1, 16, 24, 14, 1, 3, 2, 4, 1, 2, 8, 12, 24, 14, 4, 1, 8, 15, 12, 24, 23, 11, 7, 2, 1, 2, 16, 23, 18, 1, 4, 2, 3, 4, 3, 2, 8, 19, 7, 2, 2, 3, 3, 8, 15, 19, 7, 3, 1, 2, 5, 9, 24, 14, 1, 2, 3, 2, 2, 1, 4, 4, 1, 2, 5, 6, 2, 2, 2, 1, 3, 4, 3, 5, 13, 9, 24, 24, 18, 4, 3, 4, 1, 4, 1, 3, 2, 5, 13, 9, 14, 3, 1, 3, 2, 4, 4, 5, 21, 19, 12, 24, 11, 7, 1, 2, 3, 2, 1, 3, 3, 3, 20, 23, 24, 18, 4, 4, 2, 3, 1, 1, 8, 7, 5, 9, 23, 18, 1, 3, 4, 2, 4, 2, 4, 1, 2, 8, 15, 19, 7, 4, 5, 6, 4, 2, 4, 5, 17, 9, 23, 11, 22, 13, 6, 4, 1, 3, 2, 2, 4, 4, 3, 2, 1, 4, 2, 8, 7, 4, 2, 3, 16, 24, 23, 11, 7, 16, 23, 18, 3, 1, 1, 3, 1, 2, 3, 3, 3, 4, 2, 1, 3, 2, 3, 4, 3, 8, 15, 15, 7, 4, 8, 19, 7, 3, 4, 1, 2, 3, 4, 1, 3, 4, 4, 4, 1, 4, 4, 3, 2, 3, 4, 1, 2, 4, 2, 1, 2, 2, 4, 1, 4, 2, 3, 2, 1, 4, 2, 2, 1, 2, 2, 2, 4, 3, 3, 2, 3, 3, 2, 3, 2, 4, 1, 3, 1, 1, 1, 1, 4, 1, 3, 3, 2, 1, 4, 2, 1, 3, 1, 3, 3, 4, 3, 4, 2, 1, 2, 3, 1, 1], 5 | "height":25, 6 | "name":"Tile Layer 1", 7 | "opacity":1, 8 | "type":"tilelayer", 9 | "visible":true, 10 | "width":25, 11 | "x":0, 12 | "y":0 13 | }], 14 | "orientation":"isometric", 15 | "properties": 16 | { 17 | 18 | }, 19 | "tileheight":32, 20 | "tilesets":[ 21 | { 22 | "firstgid":1, 23 | "image":"..\/..\/..\/..\/..\/..\/..\/..\/..\/..\/..\/Applications\/Tiled_090_examples\/isometric_grass_and_water.png", 24 | "imageheight":384, 25 | "imagewidth":256, 26 | "margin":0, 27 | "name":"isometric_grass_and_water", 28 | "properties": 29 | { 30 | 31 | }, 32 | "spacing":0, 33 | "tileheight":64, 34 | "tileoffset": 35 | { 36 | "x":0, 37 | "y":16 38 | }, 39 | "tilewidth":64 40 | }], 41 | "tilewidth":64, 42 | "version":1, 43 | "width":25 44 | } -------------------------------------------------------------------------------- /examples/TileMaps/Tiled/TiledIsometric.data/maps/isometric_grass_and_water.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/TileMaps/Tiled/TiledIsometric.data/maps/isometric_grass_and_water.png -------------------------------------------------------------------------------- /examples/TileMaps/Tiled/TiledIsometric.monkey: -------------------------------------------------------------------------------- 1 | Strict 2 | 3 | #rem 4 | Script: TiledIsometric.monkey 5 | Description: Example script on how to use isometric tilemaps created by the tool Tiled 6 | Author: Michael Hartlef 7 | Version: 1.01 8 | #end 9 | 10 | ' Set the AutoSuspend functionality to TRUE so OnResume/OnSuspend are called 11 | #MOJO_AUTO_SUSPEND_ENABLED=True 12 | 13 | Import fantomEngine 14 | 15 | Global g:game 16 | 17 | 18 | '*************************************** 19 | Class game Extends App 20 | Field eng:engine 21 | Field tm:ftObject 22 | 23 | Field layerMap:ftLayer 24 | Field layerGUI:ftLayer 25 | Field txtInfo1:ftObject 26 | Field txtInfo2:ftObject 27 | '------------------------------------------ 28 | Method OnCreate:Int() 29 | Local c:Int 30 | 31 | ' Set the update rate of Mojo's OnUpdate to 60 FPS. 32 | SetUpdateRate(60) 33 | ' Create an instance of the fantomEngine, which was created via the engine class 34 | eng = New engine 35 | 36 | 'Set the canvas size of a usual Android canvas 37 | 'eng.SetCanvasSize(480,800) 38 | 'eng.SetCanvasSize(1024,768) 39 | 40 | 'Load the tile map created by Tiled 41 | tm = eng.CreateTileMap("maps/isometric_grass_and_water.json", 200, 30 ) 42 | 43 | 44 | 45 | 'Set its scale factor 46 | 'tm.SetScale(2) 47 | 'Set the scale mod factor for each tile of the map 48 | 'tm.SetTileSModXY(-0.1,-0.1) 49 | 50 | ' Load a bitmap font 51 | Local font:ftFont = eng.LoadFont("font.txt") 52 | 53 | ' Set and create some layers 54 | layerMap = eng.GetDefaultLayer() 55 | layerGUI = eng.CreateLayer() 56 | ' Set the GUI flag of the GUI layer so it isn't effected by the camera 57 | layerGUI.SetGUI(True) 58 | 59 | 60 | ' Create some info text objects 61 | eng.SetDefaultLayer(layerGUI) 62 | txtInfo1 = eng.CreateText(font,"FPS: 60",10,10, eng.taTopLeft) 63 | txtInfo1.SetTouchMode(ftEngine.tmBound) 64 | txtInfo1.SetName("txtInfo1") 65 | 66 | txtInfo2 = eng.CreateText(font,"0:0=0",eng.GetCanvasWidth()-10,eng.GetCanvasHeight()-10, eng.taBottomRight) 67 | txtInfo2.SetTouchMode(ftEngine.tmBound) 68 | txtInfo2.SetName("txtInfo2") 69 | 70 | Return 0 71 | End 72 | '------------------------------------------ 73 | Method OnUpdate:Int() 74 | ' Calculate the current delta time for this frame 75 | Local d:Float = Float(eng.CalcDeltaTime())/60.0 76 | 77 | ' Determine the current touch/mouse coordinates 78 | Local x:Int = eng.GetTouchX() 79 | Local y:Int = eng.GetTouchY() 80 | 81 | ' Check if the engine is paused 82 | If eng.GetPaused() = False Then 83 | 84 | ' Update all objects of the engine 85 | eng.Update(Float(d)) 86 | 87 | 'Remove a tile when you click left with the mouse 88 | If MouseHit( MOUSE_LEFT ) Then 89 | ' Do a touchcheck, if object is hit, engine.onObjectTouch is called. 90 | eng.TouchCheck() 91 | ' Remove the tile 92 | tm.SetTileIDAt(x ,y,-1) 93 | Endif 94 | 95 | 'Set a random tile when you do a right mouse click 96 | If MouseHit( MOUSE_RIGHT ) Then 97 | tm.SetTileIDAt(x, y, Rnd(0,15)) 98 | Endif 99 | 100 | 'Move the camera with the cursor keys 101 | If KeyDown(KEY_LEFT) Then eng.SetCamX(-5*d,True) 102 | If KeyDown(KEY_RIGHT) Then eng.SetCamX(5*d,True) 103 | If KeyDown(KEY_UP) Then eng.SetCamY(-5*d,True) 104 | If KeyDown(KEY_DOWN) Then eng.SetCamY(5*d,True) 105 | 106 | 'Update the info text objects 107 | txtInfo1.SetText("FPS:"+eng.GetFPS()) 108 | txtInfo2.SetText(x+":"+y+" tileID="+tm.GetTileIDAt(x,y)) 109 | 110 | 111 | Endif 112 | Return 0 113 | End 114 | '------------------------------------------ 115 | Method OnRender:Int() 116 | If eng.GetPaused()=False Then 117 | Cls 100,100,100 118 | eng.Render() 119 | Endif 120 | Return 0 121 | End 122 | '------------------------------------------ 123 | Method OnResume:Int() 124 | eng.SetPaused(False) 125 | Return 0 126 | End 127 | '------------------------------------------ 128 | Method OnSuspend:Int() 129 | eng.SetPaused(True) 130 | Return 0 131 | End 132 | End 133 | 134 | '*************************************** 135 | Class engine Extends ftEngine 136 | '------------------------------------------ 137 | ' This method is called when an object was touched. 138 | Method OnObjectTouch:Int(obj:ftObject, touchId:Int) 139 | Return 0 140 | End 141 | End 142 | 143 | '*************************************** 144 | Function Main:Int() 145 | g = New game 146 | Return 0 147 | End 148 | -------------------------------------------------------------------------------- /examples/Timers/Timers.monkey: -------------------------------------------------------------------------------- 1 | Strict 2 | 3 | #rem 4 | Script: Timer.monkey 5 | Description: Sample script to show how to use timer 6 | Author: Michael Hartlef 7 | Version: 1.01 8 | #End 9 | 10 | ' Set the AutoSuspend functionality to TRUE so OnResume/OnSuspend are called 11 | #MOJO_AUTO_SUSPEND_ENABLED=True 12 | 13 | ' Import the fantomEngine framework which imports mojo itself 14 | Import fantomEngine 15 | 16 | ' The _g variable holds an instance to the cGame class 17 | Global _g:cGame 18 | 19 | '*************************************** 20 | ' The cGame class controls the app 21 | Class cGame Extends App 22 | ' Create a field to store the instance of the cEngine class, which is an instance 23 | ' of the ftEngine class itself 24 | Field fE:cEngine 25 | 26 | ' Define two constants for timer IDs 27 | Const engineTimer:Int = 1 28 | Const objectTimer:Int = 2 29 | 30 | 31 | '------------------------------------------ 32 | Method OnCreate:Int() 33 | ' Set the update rate of Mojo's OnUpdate to 60 FPS. 34 | SetUpdateRate(60) 35 | 36 | ' Create an instance of the fantomEngine, which was created via the cEngine class 37 | fE = New cEngine 38 | 39 | ' Create a timer without a connection to an object which creates new circles at every second 40 | fE.CreateTimer(engineTimer, 500, -1) 41 | 42 | 43 | Return 0 44 | End 45 | '------------------------------------------ 46 | Method OnUpdate:Int() 47 | ' If the CLOSE key was hit, exit the app ... needed for GLFW and Android I think. 48 | If KeyHit( KEY_CLOSE ) Then fE.ExitApp() 49 | 50 | ' Determine the delta time and the update factor for the engine 51 | Local timeDelta:Float = Float(fE.CalcDeltaTime())/60.0 52 | 53 | ' Update all objects of the engine 54 | If fE.GetPaused() = False Then 55 | fE.Update(timeDelta) 56 | Endif 57 | Return 0 58 | End 59 | '------------------------------------------ 60 | Method OnRender:Int() 61 | ' Check if the engine is not paused 62 | If fE.GetPaused() = False Then 63 | ' Clear the screen 64 | Cls 255,0,0 65 | 66 | ' Render all visible objects of the engine 67 | fE.Render() 68 | Endif 69 | Return 0 70 | End 71 | End 72 | 73 | '*************************************** 74 | ' The cEngine class extends the ftEngine class to override the On... methods 75 | Class cEngine Extends ftEngine 76 | '------------------------------------------ 77 | Method OnObjectTimer:Int(timerId:Int, obj:ftObject) 78 | ' This method is called when an objects' timer was being fired. 79 | If timerId = _g.objectTimer 80 | obj.Remove() 81 | Endif 82 | Return 0 83 | End 84 | 85 | '------------------------------------------ 86 | Method OnTimer:Int(timerId:Int) 87 | ' This method is called when an engine timer was being fired. 88 | If timerId = _g.engineTimer 89 | ' Create a simple circle 90 | Local circle := self.CreateCircle(20,Rnd(self.GetCanvasWidth()),Rnd(self.GetCanvasHeight())) 91 | 92 | ' Two ways to create an object bound timer 93 | ' circle.CreateTimer(_g.objectTimer, 1500) 94 | self.CreateObjTimer(circle, _g.objectTimer, 1500) 95 | Endif 96 | Return 0 97 | End 98 | End 99 | 100 | '*************************************** 101 | Function Main:Int() 102 | ' Create an instance of the cGame class and store it inside the global var 'g' 103 | _g = New cGame 104 | 105 | Return 0 106 | End -------------------------------------------------------------------------------- /examples/Transitions/ObjectTransition/ObjectTransition.monkey: -------------------------------------------------------------------------------- 1 | Strict 2 | 3 | #rem 4 | Script: ObjectTransition.monkey 5 | Description: Sample script that shows how to use transitions to transform objects 6 | Author: Michael Hartlef 7 | Version: 1.04 8 | #End 9 | 10 | ' Set the AutoSuspend functionality to TRUE so OnResume/OnSuspend are called 11 | #MOJO_AUTO_SUSPEND_ENABLED=True 12 | 13 | ' Import the fantomEngine framework which imports mojo itself 14 | Import fantomEngine 15 | 16 | ' The _g variable holds an instance to the cGame class 17 | Global _g:cGame 18 | 19 | '*************************************** 20 | ' The cGame class controls the app 21 | Class cGame Extends App 22 | ' Create a field to store the instance of the cEngine class, which is an instance 23 | ' of the ftEngine class itself 24 | Field fE:cEngine 25 | 26 | ' Create a field for an object that we can transition 27 | Field myObj:ftObject 28 | 29 | ' Create a field to store the transition 30 | Field trans:ftTrans 31 | 32 | ' Create a constant for the transition ID. 33 | ' This will be used to identify the transition in the ftEngine.OnObjectTransition handler method. 34 | Const transDone:Int = 1 35 | 36 | '------------------------------------------ 37 | Method OnCreate:Int() 38 | ' Set the update rate of Mojo's OnUpdate to 60 FPS. 39 | SetUpdateRate(60) 40 | 41 | ' Create an instance of the fantomEngine, which was created via the cEngine class 42 | fE = New cEngine 43 | 44 | ' Create a box which represents the path the object will transition on 45 | Local tmpBox := fE.CreateBox(fE.GetCanvasWidth()-40.0,40,fE.GetCanvasWidth()/2,fE.GetCanvasHeight()/2.0) 46 | 47 | ' Create the object we want to transition 48 | myObj = fE.CreateCircle(18, 40, fE.GetCanvasHeight()/2.0) 49 | ' Set its color to Red 50 | myObj.SetColor(255,0,0) 51 | ' Set the objects Tag value which indicates in which direction it is running 52 | myObj.SetTag(1) 53 | ' Now start a transition to the other side of the canvas and store it 54 | trans = myObj.CreateTransPos((fE.GetCanvasWidth()-80) * myObj.GetTag(), 0, 4000 ,True, transDone) 55 | ' Set the equation type of the transition 56 | trans.SetType("Bounce") 57 | ' Set the ease type pf the transition 58 | trans.SetEase("EaseIn") 59 | ' Print a little info message 60 | Print ("Press the

key to pause/resume the transition") 61 | 62 | Return 0 63 | End 64 | '------------------------------------------ 65 | Method OnUpdate:Int() 66 | ' Determine the delta time and the update factor for the engine 67 | Local d:Float = Float(fE.CalcDeltaTime())/60.0 68 | 69 | ' Update all objects of the engine 70 | If fE.GetPaused() = False Then 71 | ' Check if the P key was hit 72 | If KeyHit(KEY_P) Then 73 | ' If the transition is paused, resume it. Otherwise pause it. 74 | If trans.GetPaused()=True Then 75 | trans.SetPaused(False) 76 | Else 77 | trans.SetPaused(True) 78 | Endif 79 | Endif 80 | fE.Update(d) 81 | Endif 82 | Return 0 83 | End 84 | '------------------------------------------ 85 | Method OnRender:Int() 86 | ' Check if the app is not suspended 87 | If fE.GetPaused() = False Then 88 | ' Clear the screen 89 | Cls 90 | 91 | ' Render all visible objects of the engine 92 | fE.Render() 93 | Endif 94 | Return 0 95 | End 96 | '------------------------------------------ 97 | Method OnResume:Int() 98 | ' Set the pause flag of the engine to FALSE so objects, timers and transitions are updated again 99 | fE.SetPaused(false) 100 | 101 | Return 0 102 | End 103 | '------------------------------------------ 104 | Method OnSuspend:Int() 105 | ' Set the pause flag of the engine to TRUE so objects, timers and transitions are paused (not updated) 106 | fE.SetPaused(True) 107 | 108 | Return 0 109 | End 110 | End 111 | 112 | '*************************************** 113 | ' The cEngine class extends the ftEngine class to override the On... methods 114 | Class cEngine Extends ftEngine 115 | '------------------------------------------ 116 | Method OnObjectTransition:Int(transId:Int, obj:ftObject) 117 | ' This method is called when an object finishes its transition 118 | If transId = _g.transDone Then 119 | ' Negate the Tag value of the object 120 | obj.SetTag(obj.GetTag()*-1) 121 | ' Start a new transtion for this object 122 | _g.trans = obj.CreateTransPos((_g.fE.GetCanvasWidth()-80) * obj.GetTag(), 0, 4000 ,True, _g.transDone) 123 | ' Set the equation type of the transition 124 | _g.trans.SetType("Back") 125 | ' Set the ease type pf the transition 126 | _g.trans.SetEase("EaseInOut") 127 | Endif 128 | Return 0 129 | End 130 | End 131 | 132 | '*************************************** 133 | Function Main:Int() 134 | ' Create an instance of the cGame class and store it inside the global var 'g' 135 | _g = New cGame 136 | 137 | Return 0 138 | End 139 | -------------------------------------------------------------------------------- /examples/Transitions/ObjectTransition/ObjectTransitionImage.data/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Transitions/ObjectTransition/ObjectTransitionImage.data/image.png -------------------------------------------------------------------------------- /examples/Transitions/ObjectTransition/ObjectTransitionImage.monkey: -------------------------------------------------------------------------------- 1 | Strict 2 | 3 | #rem 4 | Script: ObjectTransitionImage.monkey 5 | Description: Sample script that shows how to use transitions to transform image objects 6 | Author: Michael Hartlef 7 | Version: 1.05 8 | #End 9 | 10 | ' Set the AutoSuspend functionality to TRUE so OnResume/OnSuspend are called 11 | #MOJO_AUTO_SUSPEND_ENABLED=True 12 | 13 | ' Import the fantomEngine framework which imports mojo itself 14 | Import fantomEngine 15 | 16 | ' The _g variable holds an instance to the cGame class 17 | Global _g:cGame 18 | 19 | '*************************************** 20 | ' The cGame class controls the app 21 | Class cGame Extends App 22 | ' Create a field to store the instance of the cEngine class, which is an instance 23 | ' of the ftEngine class itself 24 | Field fE:cEngine 25 | 26 | ' Create a field to store the transition 27 | Field trans:ftTrans 28 | 29 | ' Create a constant for the transition ID. 30 | ' This will be used to identify the transition in the ftEngine.OnObjectTransition handler method. 31 | Const transDone:Int = 1 32 | 33 | '------------------------------------------ 34 | Method OnCreate:Int() 35 | ' Set the update rate of Mojo's OnUpdate to 60 FPS. 36 | SetUpdateRate(60) 37 | 38 | ' Create an instance of the fantomEngine, which was created via the cEngine class 39 | fE = New cEngine 40 | 'fE.SetCanvasSize(480,320) 41 | ' Create a box object we want to transition 42 | Local tmpBox := fE.CreateBox(128,128,-100,fE.GetCanvasHeight()/4.0) 43 | tmpBox.SetTag(1) 44 | 45 | ' Create the image object we want to transition 46 | Local tmpImage := fE.CreateImage("image.png", -100, (fE.GetCanvasHeight()/4.0)*3) 47 | tmpImage.SetTag(1) 48 | ' Scale the image up to 150% 49 | tmpImage.SetScale(1.5) 50 | 51 | ' Now start a transition to the other side of the canvas and store it 52 | trans = tmpBox.CreateTransPos(fE.GetCanvasWidth()+200, 0, 6000 ,True, transDone) 53 | ' Set the equation type of the transition 54 | trans.SetType("Cubic") 55 | ' Set the ease type pf the transition 56 | trans.SetEase("EaseInOut") 57 | 58 | 59 | trans = tmpImage.CreateTransPos(fE.GetCanvasWidth()+200, 0, 6000 ,True, transDone) 60 | ' Set the equation type of the transition 61 | trans.SetType("Cubic") 62 | ' Set the ease type pf the transition 63 | trans.SetEase("EaseInOut") 64 | ' Print a little info message 65 | 'Print ("Press the

key to pause/resume the transition") 66 | 67 | 'fE.SetPaused(True) 68 | 69 | Return 0 70 | End 71 | '------------------------------------------ 72 | Method OnUpdate:Int() 73 | ' Determine the delta time and the update factor for the engine 74 | Local d:Float = Float(fE.CalcDeltaTime())/60.0 75 | 76 | If KeyHit(KEY_P) = True Then 77 | If fE.GetPaused()=True Then 78 | fE.SetPaused(False) 79 | Else 80 | fE.SetPaused(True) 81 | Endif 82 | Endif 83 | 84 | fE.Update(d) 85 | 86 | Return 0 87 | End 88 | '------------------------------------------ 89 | Method OnRender:Int() 90 | ' Check if the app is not suspended 91 | If fE.GetPaused() = False Then 92 | ' Clear the screen 93 | Cls 94 | 95 | ' Render all visible objects of the engine 96 | fE.Render() 97 | Endif 98 | Return 0 99 | End 100 | '------------------------------------------ 101 | Method OnResume:Int() 102 | ' Set the pause flag of the engine to FALSE so objects, timers and transitions are updated again 103 | fE.SetPaused(false) 104 | 105 | Return 0 106 | End 107 | '------------------------------------------ 108 | Method OnSuspend:Int() 109 | ' Set the pause flag of the engine to TRUE so objects, timers and transitions are paused (not updated) 110 | fE.SetPaused(True) 111 | 112 | Return 0 113 | End 114 | End 115 | 116 | '*************************************** 117 | ' The cEngine class extends the ftEngine class to override the On... methods 118 | Class cEngine Extends ftEngine 119 | '------------------------------------------ 120 | Method OnObjectTransition:Int(transId:Int, obj:ftObject) 121 | ' This method is called when an object finishes its transition 122 | If transId = _g.transDone Then 123 | ' Negate the Tag value of the object 124 | obj.SetTag(obj.GetTag()*-1) 125 | ' Start a new transtion for this object 126 | _g.trans = obj.CreateTransPos((_g.fE.GetCanvasWidth() + 200) * obj.GetTag(), 0, 6000 ,True, _g.transDone) 127 | ' Set the equation type of the transition 128 | _g.trans.SetType("Cubic") 129 | ' Set the ease type pf the transition 130 | _g.trans.SetEase("EaseInOut") 131 | Endif 132 | Return 0 133 | End 134 | End 135 | 136 | '*************************************** 137 | Function Main:Int() 138 | ' Create an instance of the cGame class and store it inside the global var 'g' 139 | _g = New cGame 140 | 141 | Return 0 142 | End 143 | -------------------------------------------------------------------------------- /examples/Waypoints/Waypoints.data/CarSprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MikeHart66/fantomEngine/41dd816c40d6e6bc815e6e36b332d5f759b5bcd7/examples/Waypoints/Waypoints.data/CarSprite.png -------------------------------------------------------------------------------- /examples/Waypoints/Waypoints.monkey: -------------------------------------------------------------------------------- 1 | 2 | Strict 3 | 4 | #rem 5 | Script: Waypoints.monkey 6 | Description: Example script on how to use waypoints 7 | Author: Michael Hartlef 8 | Version: 1.04 9 | #End 10 | 11 | ' Set the AutoSuspend functionality to TRUE so OnResume/OnSuspend are called 12 | #MOJO_AUTO_SUSPEND_ENABLED=True 13 | 14 | ' Import the fantomEngine framework which imports mojo itself 15 | Import fantomEngine 16 | 17 | ' The g variable holds an instance to the game class 18 | Global g:game 19 | 20 | '*************************************** 21 | ' The game class controls the app 22 | Class game Extends App 23 | ' Create a field to store the instance of the engine class, which is an instance 24 | ' of the ftEngine class itself 25 | Field eng:engine 26 | 27 | ' Create a field for a waypoint path 28 | Field path:ftPath 29 | 30 | ' Create a path marker, that object that runs along a path 31 | Field mk:ftMarker 32 | 33 | '------------------------------------------ 34 | Method OnCreate:Int() 35 | ' Set the update rate of Mojo's OnUpdate to 60 FPS. 36 | SetUpdateRate(60) 37 | 38 | ' Create an instance of the fantomEngine, which was created via the engine class 39 | eng = New engine 40 | 41 | ' Now set the virtual canvas size 42 | eng.SetCanvasSize(800,600) 43 | 44 | ' Now create a path with its origin at the center of the canvas 45 | path = eng.CreatePath(eng.GetCanvasWidth()/2, eng.GetCanvasHeight()/2) 46 | 47 | 48 | ' Create 4 waypoints 49 | path.AddWP( -150,-150, True) 50 | path.AddWP( 150,-150, True) 51 | path.AddWP( 150,150, True) 52 | path.AddWP( -150,150, True) 53 | 54 | ' Create a marker 55 | mk = path.CreateMarker() 56 | 57 | ' Connect a new image object to the marker 58 | mk.ConnectObj(eng.CreateImage("CarSprite.png",0,0)) 59 | 60 | ' Let the marker circle around the path 61 | mk.SetMoveMode(path.mmCircle) 62 | 63 | ' Set its interpolation mode to CatMull Rom spline 64 | mk.SetInterpolationMode(path.imCatmull) 65 | 66 | Return 0 67 | End 68 | '------------------------------------------ 69 | Method OnUpdate:Int() 70 | ' Determine the delta time and the update factor for the engine 71 | Local d:Float = Float(eng.CalcDeltaTime())/60.0 72 | 73 | ' Update all objects of the engine 74 | eng.Update(d) 75 | 76 | ' Check if the engine is not paused 77 | If eng.GetPaused() = False Then 78 | ' Update all path marker and their connected objects 79 | path.UpdateAllMarker(d*10) 80 | 81 | ' Scale the path when you press the Q or A key 82 | If KeyDown(KEY_Q) Then 83 | path.SetScale(-0.01,-0.01,True) 84 | Endif 85 | If KeyDown(KEY_A) Then 86 | path.SetScale(0.01,0.01,True) 87 | Endif 88 | 89 | ' Move the path when you press the UP/DOWN key 90 | If KeyDown(KEY_UP) Then 91 | path.SetPos(0,-1,True) 92 | Endif 93 | If KeyDown(KEY_DOWN) Then 94 | path.SetPos(0,1,True) 95 | Endif 96 | 97 | ' Turn the path when you press the RIGHT/LEFT key 98 | If KeyDown(KEY_RIGHT) Then 99 | path.SetAngle(0.5,True) 100 | Endif 101 | If KeyDown(KEY_LEFT) Then 102 | path.SetAngle(-0.5,True) 103 | Endif 104 | 105 | Endif 106 | ' End the app when you press the ESCAPE key 107 | If KeyHit(KEY_ESCAPE) Then eng.ExitApp 108 | Return 0 109 | End 110 | '------------------------------------------ 111 | Method OnRender:Int() 112 | ' Check if the engine is not paused 113 | If eng.GetPaused() = False Then 114 | ' Clear the screen 115 | Cls 116 | 117 | ' Render the waypoints of the path 118 | SetColor(0,0,255) 119 | path.RenderAllWP() 120 | 121 | ' Render all visible objects of the engine 122 | eng.Render() 123 | Endif 124 | Return 0 125 | End 126 | '------------------------------------------ 127 | Method OnResume:Int() 128 | ' Set the state of the app being not suspended 129 | eng.SetPaused(False) 130 | Return 0 131 | End 132 | '------------------------------------------ 133 | Method OnSuspend:Int() 134 | ' Set the state of the app being suspended 135 | eng.SetPaused(True) 136 | Return 0 137 | End 138 | End 139 | 140 | '*************************************** 141 | ' The engine class extends the ftEngine class to override the On... methods 142 | Class engine Extends ftEngine 143 | '------------------------------------------ 144 | Method OnMarkerCircle:Int(marker:ftMarker, obj:ftObject) 145 | Print ("One round is finished") 146 | Return 0 147 | End 148 | 149 | 150 | End 151 | 152 | '*************************************** 153 | Function Main:Int() 154 | ' Create an instance of the game class and store it inside the global var 'g' 155 | g = New game 156 | 157 | Return 0 158 | End 159 | -------------------------------------------------------------------------------- /fantomEngine.monkey: -------------------------------------------------------------------------------- 1 | #rem 2 | 'Title: fantomEngine 3 | 'Description: A 2D game framework for the Monkey programming language 4 | 5 | 'Author: Michael Hartlef 6 | 'Contact: michaelhartlef@gmail.com 7 | 8 | 'Website: http://www.fantomgl.com 9 | 10 | 'Version: 1.58 11 | 'License: MIT 12 | #End 13 | 14 | #Rem 15 | 'header:The module [b]fantomEngine[/b] is a 2D game framework which supplies you with huge set of game object related functionalities. 16 | To use fantomEngine in your game, simply add "Import fantomEngine" at the top of your program. 17 | #End 18 | 19 | 20 | Import mojo 21 | Import brl.pool 22 | 23 | 'If TARGET="html5" 24 | Import "data/ftLoadingBar.png" 25 | Import "data/ftOrientation_changeP.png" 26 | Import "data/ftOrientation_changeL.png" 27 | 'End 28 | 29 | 'Import reflection 30 | '#REFLECTION_FILTER+="|fantomEngine.cftLayer" 31 | '#REFLECTION_FILTER+="|fantomEngine*" 32 | 33 | Import fantomEngine.cftMisc 34 | Import fantomEngine.cftFunctions 35 | Import fantomEngine.cftImageMng 36 | Import fantomEngine.cftObject 37 | Import fantomEngine.cftObjAnimMng 38 | Import fantomEngine.cftLayer 39 | Import fantomEngine.cftEngine 40 | Import fantomEngine.cftSound 41 | Import fantomEngine.cftTimer 42 | Import fantomEngine.cftFont 43 | Import fantomEngine.cftTrans 44 | Import fantomEngine.cftHighscore 45 | Import fantomEngine.cftSwipe 46 | Import fantomEngine.cftWaypoints 47 | Import fantomEngine.cftAStar 48 | Import fantomEngine.cftLocalization 49 | Import fantomEngine.cftKeyMapping 50 | Import fantomEngine.cftTileMap 51 | Import fantomEngine.cftSpriteAtlas 52 | Import fantomEngine.cftRGBA 53 | Import fantomEngine.cftVec2D 54 | Import fantomEngine.cftScene 55 | Import fantomEngine.cftGui 56 | 57 | #If TARGET="DocMonk" 58 | Import fantomEngine.cftBox2D 59 | #End 60 | 61 | Import json 62 | 63 | '-OUTPUTNAME#index.html 64 | '#INCLFILE#docInclude/introduction.txt 65 | '-INCLFILE#docInclude/classes.txt 66 | '-INCLFILE#docInclude/3rdpartytools.txt 67 | '-INCLFILE#docInclude/examples.txt 68 | '-INCLFILE#docInclude/changes.txt 69 | #rem 70 | footer:This fantomEngine framework is released under the MIT license: 71 | [quote]Copyright (c) 2011-2016 Michael Hartlef 72 | 73 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the software, and to permit persons to whom the software is furnished to do so, subject to the following conditions: 74 | 75 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the software. 76 | 77 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 78 | [/quote] 79 | #end -------------------------------------------------------------------------------- /fantomEngine_license.txt: -------------------------------------------------------------------------------- 1 | fantomEngine - A 2D game framework module for the Monkey programming language 2 | 3 | Copyright (c) 2011-2016 Michael Hartlef 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), 6 | to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | and/or sell copies of the software, and to permit persons to whom the software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 12 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 13 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 14 | -------------------------------------------------------------------------------- /monkeydoc/cftFont.monkeydoc: -------------------------------------------------------------------------------- 1 | # Module cftFont 2 | 3 | The module cftFont hosts several classes which add bitmap font drawing to fantomEngine. Bitmap fonts are important if you need to show text information inside your game fast and easy. 4 | 5 | # Import fantomEngine 6 | 7 | # Class cftFont.ftFont 8 | 9 | The class ftFont provides a few methods regarding the definition of a loaded font. 10 | 11 | # Method Height:Int() 12 | 13 | *Description* 14 | 15 | Returns the maximum height of the font. 16 | 17 | Links: [[Height]] 18 | 19 | # Method Length:Int(t:String) 20 | 21 | *Description* 22 | 23 | Returns the length in pixel of the given text string. 24 | 25 | Links: [[Length]] 26 | 27 | -------------------------------------------------------------------------------- /monkeydoc/cftFunctions.monkeydoc: -------------------------------------------------------------------------------- 1 | # Module cftFunctions 2 | 3 | The module cftFunctions is a collection of several functions for IOS, ANDROID and HTML5 targets to retrieve some device and browser informations. 4 | 5 | # Function GetBrowserName:String() 6 | 7 | *Description* 8 | 9 | Returns the name of the HTML5 browser. 10 | 11 | *Details* 12 | 13 | Returns valid information on HTML5 only. 14 | 15 | # Function GetBrowserPlatform:String() 16 | 17 | *Description* 18 | 19 | Returns the platform the HTML5 browser is running on. 20 | 21 | *Details* 22 | 23 | Returns valid information on HTML5 only. 24 | 25 | # Function GetBrowserVersion:String() 26 | 27 | *Description* 28 | 29 | Returns the version of the HTML5 browser. 30 | 31 | *Details* 32 | 33 | Returns valid information on HTML5 only. 34 | 35 | # Function GetDeviceName:String() 36 | 37 | *Description* 38 | 39 | Returns the name of the device. 40 | 41 | *Details* 42 | 43 | Returns valid information on Android/iOS only. 44 | 45 | # Function GetHardware:String() 46 | 47 | *Description* 48 | 49 | Returns the hardware of the device. 50 | 51 | *Details* 52 | 53 | Returns valid information on Android/iOS only. 54 | 55 | # Function GetLanguage:String() 56 | 57 | *Description* 58 | 59 | Returns the language of a browser. 60 | 61 | *Details* 62 | 63 | Returns valid information on HTML5 only. 64 | 65 | # Function GetProduct:String() 66 | 67 | *Description* 68 | 69 | Return the product of the device. 70 | 71 | *Details* 72 | 73 | Returns valid information on Android only. 74 | 75 | # Function GetSerial:String() 76 | 77 | *Description* 78 | 79 | Return the serial number of the device. 80 | 81 | *Details* 82 | 83 | Returns valid information on Android/iOS only. 84 | 85 | # Function GetUser:String() 86 | 87 | *Description* 88 | 89 | Returns the name of the device user. 90 | 91 | *Details* 92 | 93 | Returns valid information on Android/iOS only. 94 | 95 | # Function HideConsole:Void() 96 | 97 | *Description* 98 | 99 | Hides the HTML5 console. 100 | 101 | *Details* 102 | 103 | HTML5 only. 104 | 105 | Attention: You need to set the variable CANVAS_RESIZE_MODE to 0 in your exported MonkeyGame.html file to make this work correctly! 106 | 107 | # Function IsMobileBrowser:Bool() 108 | 109 | *Description* 110 | 111 | Returns TRUE, if your HTML5 runs on a mobile browser. 112 | 113 | *Details* 114 | 115 | Returns valid information on HTML5 only. 116 | 117 | # Function MaximizeCanvas:Void() 118 | 119 | *Description* 120 | 121 | Maximizes the HTML5 canvas. 122 | 123 | *Details* 124 | 125 | HTML5 only. 126 | 127 | Attention: You need to set the variable CANVAS_RESIZE_MODE to 0 in your exported MonkeyGame.html file to make this work correctly! 128 | 129 | # Function ResizeCanvas:Void(x:Int, y:Int) 130 | 131 | *Description* 132 | 133 | Resizes the HTML5 canvas to the given proportions. 134 | 135 | *Details* 136 | 137 | HTML5 only. 138 | 139 | Attention: You need to set the variable CANVAS_RESIZE_MODE to 0 in your exported MonkeyGame.html file to make this work correctly! 140 | 141 | # Function ResizeConsole:Void(x:Int, y:Int) 142 | 143 | *Description* 144 | 145 | Resizes the HTML5 console to the given proportions. 146 | 147 | *Details* 148 | 149 | HTML5 only. 150 | 151 | Attention: You need to set the variable CANVAS_RESIZE_MODE to 0 in your exported MonkeyGame.html file to make this work correctly! 152 | 153 | -------------------------------------------------------------------------------- /monkeydoc/cftHighscore.monkeydoc: -------------------------------------------------------------------------------- 1 | # Module cftHighscore 2 | 3 | The module cftHighScore adds an easy to manage local highscore list to your game. 4 | 5 | # Import fantomEngine 6 | 7 | # Class cftHighscore.ftHighScoreList 8 | 9 | The class ftHighScoreList offers a complete set of methods for storing and retrieving high-score list entries. 10 | 11 | # Method AddScore:Int(value:Int, n:String="") 12 | 13 | *Description* 14 | 15 | Tries to add a new entry to the list. Returns the new rank if it is in the list. Returns 0 if not. 16 | 17 | Links: [[GetName]], [[GetValue]] 18 | 19 | # Method Clear:Void() 20 | 21 | *Description* 22 | 23 | Clears the complete high-score list. 24 | 25 | # Method Count:Int() 26 | 27 | *Description* 28 | 29 | Get the numbers of entries. 30 | 31 | Links: [[AddScore]], [[LoadFromString]] 32 | 33 | # Method GetName:String(i:Int) 34 | 35 | *Description* 36 | 37 | Get the name of an entry. 38 | 39 | Links: [[GetValue]], [[AddScore]] 40 | 41 | # Method GetValue:Int(i:Int) 42 | 43 | *Description* 44 | 45 | Get the value of an entry. 46 | 47 | Links: [[GetName]], [[AddScore]] 48 | 49 | # Method LoadFromString:Void(hs:String) 50 | 51 | *Description* 52 | 53 | Load a high-score list from a string. 54 | 55 | Links: [[Count]], [[SaveToString]] 56 | 57 | # Method SaveToString:String() 58 | 59 | *Description* 60 | 61 | Save the high-score list to a string. 62 | 63 | Links: [[LoadFromString]] 64 | 65 | # Method SetCount:Void(count:Int = 10) 66 | 67 | *Description* 68 | 69 | Set the number of highscore entries. 70 | 71 | Links: [[Count]] 72 | 73 | -------------------------------------------------------------------------------- /monkeydoc/cftImageMng.monkeydoc: -------------------------------------------------------------------------------- 1 | # Module cftImageMng 2 | 3 | The module cftImageMng contains several classes to manage loaded images inside your game. 4 | 5 | # Import fantomEngine 6 | 7 | # Class cftImageMng.ftImage 8 | 9 | The ftImage class contains a mojo image and some information about. 10 | 11 | # Method GetFrameCount:Int() 12 | 13 | *Description* 14 | 15 | Returns the frame count of a ftImage. 16 | 17 | # Method GetFrameHeight:Int() 18 | 19 | *Description* 20 | 21 | Returns the frame height of a ftImage. 22 | 23 | # Method GetFrameWidth:Int() 24 | 25 | *Description* 26 | 27 | Returns the frame width of a ftImage. 28 | 29 | # Method GetImage:Image() 30 | 31 | # Method GetPath:String() 32 | 33 | *Description* 34 | 35 | Returns the path (filename) of a ftImage. 36 | 37 | # Method ReLoad:Void() 38 | 39 | *Description* 40 | 41 | Reloads an image. 42 | 43 | # Method Remove:Void(discard:Bool = False) 44 | 45 | *Description* 46 | 47 | Removes an ftImage. 48 | 49 | # Method SetPath:String(filePath:String) 50 | 51 | *Description* 52 | 53 | Sets the path (filename) of a ftImage. 54 | 55 | # Class cftImageMng.ftImageManager 56 | 57 | The ftImageManager class handles all images for fantomEngine. 58 | 59 | # Method GrabImage:ftImage(atlas:ftImage, frameStartX:Int,frameStartY:Int,frameWidth:Int,frameHeight:Int,frameCount:Int, flags:Int=Image.DefaultFlags) 60 | 61 | *Description* 62 | 63 | Creates an ftImage by grabbing it from a ftImage atlas. 64 | 65 | # Method GrabImage:ftImage(atlas:Image, frameStartX:Int,frameStartY:Int,frameWidth:Int,frameHeight:Int,frameCount:Int, flags:Int=Image.DefaultFlags) 66 | 67 | *Description* 68 | 69 | Creates an ftImage by grabbing it from a Image atlas. 70 | 71 | # Method LoadImage:ftImage(image:Image) 72 | 73 | *Description* 74 | 75 | Creates an ftImage from an image. 76 | 77 | # Method LoadImage:ftImage(path:String, frameCount:Int=1, flags:Int=Image.DefaultFlags) 78 | 79 | *Description* 80 | 81 | Loads an image like mogo.LoadImage. 82 | 83 | # Method LoadImage:ftImage(path:String, frameWidth:Int, frameHeight:Int, frameCount:Int, flags:Int=Image.DefaultFlags) 84 | 85 | *Description* 86 | 87 | Loads an image like mogo.LoadImage. 88 | 89 | # Method ReLoadAllImages:Void() 90 | 91 | *Description* 92 | 93 | Reload all images. 94 | 95 | # Method RemoveAllImages:Void(discard:Bool = False) 96 | 97 | *Description* 98 | 99 | Removes all images from the image handler. 100 | 101 | # Method RemoveImage:Void(image:Image, discard:Bool = False) 102 | 103 | *Description* 104 | 105 | Removes an image from the image handler by the given Image handle. 106 | 107 | # Method RemoveImage:Void(filepath:String, discard:Bool = False) 108 | 109 | *Description* 110 | 111 | Removes an image from the image handler by the given filename. 112 | 113 | -------------------------------------------------------------------------------- /monkeydoc/cftLocalization.monkeydoc: -------------------------------------------------------------------------------- 1 | # Module cftLocalization 2 | 3 | The module *cftLocalization* contains... 4 | 5 | # Import fantomEngine 6 | 7 | # Class cftLocalization.ftLocalization 8 | 9 | The class *ftLocalization* is an object which helps you supporting multiple languages in your app. 10 | 11 | # Method Clear:Void() 12 | 13 | *Description* 14 | 15 | This method clears all the mapping data. 16 | 17 | # Method GetDefaultLanguage:String() 18 | 19 | *Description* 20 | 21 | This method returns the default language. 22 | 23 | Links: [[SetDefaultLanguage]] 24 | 25 | # Method GetString:String(text:String, langStr:String="") 26 | 27 | *Description* 28 | 29 | This method returns the translated string. 30 | 31 | *Details* 32 | 33 | If no langStr is given, it will use the default language. 34 | 35 | Links: [[LoadFromString]], [[SetDefaultLanguage]] 36 | 37 | # Method LoadFromString:Void(locStr:String) 38 | 39 | *Description* 40 | 41 | This method loads the localization class via a string 42 | 43 | *Details* 44 | 45 | The format of the string has to be (key%;%LanguageShortCut1%:%Translation1%;%...): 46 | 47 | Play%;%DE%:%Spielen 48 | 49 | Options%;%DE%:%Optionen 50 | 51 | Help%;%DE%:%Hilfe 52 | 53 | MultiLine%;%DE%:%Dieser Text%LF%erscheint in 2 Zeilen 54 | 55 | Links: [[GetString]], [[SetDefaultLanguage]] 56 | 57 | # Method SetDefaultLanguage:Void(defLang:String ="EN") 58 | 59 | *Description* 60 | 61 | This method sets the default language. 62 | 63 | Links: [[GetString]], [[GetDefaultLanguage]] 64 | 65 | -------------------------------------------------------------------------------- /monkeydoc/cftMisc.monkeydoc: -------------------------------------------------------------------------------- 1 | # Module cftMisc 2 | 3 | # Import fantomEngine 4 | 5 | # Function GetPitchRate:Float(halfStep:Float, base:Float=1.0) 6 | 7 | *Description* 8 | 9 | Calculates the pitchrate for the amount of given halfsteps. 10 | 11 | *Details* 12 | 13 | The default base note is 'A4' 14 | 15 | -------------------------------------------------------------------------------- /monkeydoc/cftObjAnimMng.monkeydoc: -------------------------------------------------------------------------------- 1 | # Module cftObjAnimMng 2 | 3 | The module cftObjAnimMng contains several classes to manage animated objects inside your game. 4 | 5 | # Import fantomEngine 6 | 7 | # Class cftObjAnimMng.ftAnim 8 | 9 | The ftAnim class represents one animation of an object. 10 | 11 | # Method AddFrame:Void(_imgIndex:Int, _frameIndex:Int) 12 | 13 | *Description* 14 | 15 | Adds a frame to an animated object. 16 | 17 | # Method Update:Void(delta:Float = 1.0) 18 | 19 | *Description* 20 | 21 | Updates the animation of an object. 22 | 23 | # Class cftObjAnimMng.ftObjAnimMng 24 | 25 | The ftObjAnimMng class manages the animations of an object. 26 | 27 | # Method AddAnim:Void(animName:String, imgIndex:Int, _frameStart:Int = 1, _frameEnd:Int = 1) 28 | 29 | *Description* 30 | 31 | Add to an existing animation. Image and frame indexes start at 1. 32 | 33 | # Method CreateAnim:Void(animName:String, imgIndex:Int, _frameStart:Int = 1, _frameEnd:Int = 1) 34 | 35 | *Description* 36 | 37 | Creates a new animation. Image and frame indexes start at 1. 38 | 39 | # Method GetCurrAnimCount:Int() 40 | 41 | *Description* 42 | 43 | Get the number of frames from the active animation. 44 | 45 | # Method GetCurrAnimFrame:Float() 46 | 47 | *Description* 48 | 49 | Get the current frame of the active animation. 50 | 51 | # Method GetCurrAnimName:String() 52 | 53 | *Description* 54 | 55 | Get the animation name. 56 | 57 | # Method GetCurrAnimTime:Float() 58 | 59 | *Description* 60 | 61 | Get the animation frame time. 62 | 63 | # Method RemoveAll:Void() 64 | 65 | *Description* 66 | 67 | Remove all animations. 68 | 69 | # Method SetActiveAnim:Void(animName:String) 70 | 71 | *Description* 72 | 73 | Set the current active anim 74 | 75 | # Method SetCurrAnimFrame:Void(frame:Float) 76 | 77 | *Description* 78 | 79 | Set the frame of the current animation. The frame number starts with 1. 80 | 81 | # Method SetCurrAnimRepeatCount:Void(repeatCount:Int = -1) 82 | 83 | *Description* 84 | 85 | Set the repeat count of the current animation. 86 | 87 | *Details* 88 | 89 | The default value of -1 means it runs forever. A value greater than 0 describes how many times the animation repeats itself. 90 | 91 | # Method SetCurrAnimTime:Void(time:Float = 10.0) 92 | 93 | *Description* 94 | 95 | Set the factor for the frame time of the current animation. 96 | 97 | *Details* 98 | 99 | The default value is 10.0. The higher the value is, the longer a frame is displayed. 100 | 101 | # Method UpdateCurrAnim:Void(delta:Float = 1.0) 102 | 103 | -------------------------------------------------------------------------------- /monkeydoc/cftRGBA.monkeydoc: -------------------------------------------------------------------------------- 1 | # Module cftRGBA 2 | 3 | The cftRGBA module provides a RGBA color class. 4 | 5 | # Import fantomEngine 6 | 7 | # Class cftRGBA.ftRGBA 8 | 9 | # Method Add:Void(_red:Float, _green:Float, _blue:Float, _alpha:Float=-1.0) 10 | 11 | # Method Add:Void(color:ftRGBA) 12 | 13 | # Method Copy:ftRGBA() 14 | 15 | # Method Inverse:Void(inklAlpha:Bool = False) 16 | 17 | # Method Multiply:Void(_red:Float, _green:Float, _blue:Float, _alpha:Float=-1.0) 18 | 19 | # Method Multiply:Void(color:ftRGBA) 20 | 21 | # Method New:none(_red:Float, _green:Float, _blue:Float, _alpha:Float=-1.0) 22 | 23 | # Method Set:Void(color:ftRGBA) 24 | 25 | # Method Set:Void(_red:Float, _green:Float, _blue:Float, _alpha:Float=-1.0) 26 | 27 | # Method Sub:Void(_red:Float, _green:Float, _blue:Float, _alpha:Float=-1.0) 28 | 29 | # Method Sub:Void(color:ftRGBA) 30 | 31 | -------------------------------------------------------------------------------- /monkeydoc/cftScene.monkeydoc: -------------------------------------------------------------------------------- 1 | # Module cftScene 2 | 3 | The class *ftScene* groups assigned layers and lets you manage them in a combined way. Layers can be connected to several scenes at one time. 4 | 5 | # Import fantomEngine 6 | 7 | # Class cftScene.ftScene 8 | 9 | # Method AddLayer:Void(layer:ftLayer) 10 | 11 | *Description* 12 | 13 | Add a layer to a scene. 14 | 15 | Links: [[RemoveLayer]] 16 | 17 | # Method CreateTransAlpha:ftTrans(alpha:Float, duration:Float, relative:Int, transId:Int=0) 18 | 19 | *Description* 20 | 21 | Create an alpha transition for the scene. 22 | 23 | *Details* 24 | 25 | The duration is the time in milliseconds, the transition takes to complete. Only a transID > 0 will fire the ftEngine.OnLayerTrans method for the first layer of a scene. 26 | 27 | Links: [[CreateTransPos]] 28 | 29 | # Method CreateTransPos:ftTrans(xt:Float, yt:Float, duration:Float, relative:Int, transId:Int=0) 30 | 31 | *Description* 32 | 33 | Create an position transition for the scene. 34 | 35 | *Details* 36 | 37 | The duration is the time in milliseconds, the transition takes to complete. Only a transID > 0 will fire the ftEngine.OnLayerTrans method for the first layer of a scene. 38 | 39 | Links: [[CreateTransAlpha]] 40 | 41 | # Method GetActive:Bool() 42 | 43 | *Description* 44 | 45 | Returns the active flag of the scene. 46 | 47 | Links: [[SetActive]] 48 | 49 | # Method GetVisible:Bool() 50 | 51 | *Description* 52 | 53 | Returns the visible flag of the scene. 54 | 55 | Links: [[SetVisible]] 56 | 57 | # Method Remove:Void() 58 | 59 | *Description* 60 | 61 | Remove the scene from the engine. 62 | 63 | # Method RemoveLayer:Void(layer:ftLayer) 64 | 65 | *Description* 66 | 67 | Remove a layer from a scene. 68 | 69 | Links: [[AddLayer]] 70 | 71 | # Method SetActive:Void(activeFlag:Bool) 72 | 73 | *Description* 74 | 75 | Set the active flag of the scenes layers. 76 | 77 | Links: [[GetActive]] 78 | 79 | # Method SetAlpha:Void(newAlpha:Float, relative:Bool = False) 80 | 81 | *Description* 82 | 83 | Set the alpha value of each layer in the scene. 84 | 85 | Links: [[SetPos]] 86 | 87 | # Method SetPos:Void(x:Float, y:Float, relative:Bool = False) 88 | 89 | *Description* 90 | 91 | Set the position of each layer in the scene. 92 | 93 | Links: [[SetAlpha]] 94 | 95 | # Method SetVisible:Void(visibleFlag:Bool) 96 | 97 | *Description* 98 | 99 | Set the visible flag of the scenes layers. 100 | 101 | Links: [[GetVisible]] 102 | 103 | -------------------------------------------------------------------------------- /monkeydoc/cftSound.monkeydoc: -------------------------------------------------------------------------------- 1 | # Module cftSound 2 | 3 | # Import fantomEngine 4 | 5 | # Class cftSound.ftSound 6 | 7 | The class *ftSound* is an object to play sounds easily. 8 | 9 | # Method GetFreeSoundChannel:Int() 10 | 11 | *Description* 12 | 13 | Returns a free sound channel index. 14 | 15 | # Method GetPan:Float() 16 | 17 | *Description* 18 | 19 | Returns the pan value of a sound. 20 | 21 | Links: [[SetPan]] 22 | 23 | # Method GetPaused:Bool() 24 | 25 | *Description* 26 | 27 | Returns the flag of a sound. 28 | 29 | Links: [[SetPaused]] 30 | 31 | # Method GetPitchRate:Float() 32 | 33 | *Description* 34 | 35 | Returns the pitch rate of a sound. 36 | 37 | Links: [[SetPitchRate]] 38 | 39 | # Method GetVolume:Float() 40 | 41 | *Description* 42 | 43 | Returns the volume of a sound. Ranges from 0.0 to 1.0. 44 | 45 | Links: [[SetVolume]] 46 | 47 | # Method Play:Int(c:Int = -1) 48 | 49 | *Description* 50 | 51 | Plays a sound. If no channel is provided, fantomEngine will determine the channel automatically. 52 | 53 | Links: [[Stop]] 54 | 55 | # Method SetPan:Void(channelPan:Float = 0.0) 56 | 57 | *Description* 58 | 59 | Set the pan value of a sound. Ranges from -1.0 to 1.0. 60 | 61 | *Details* 62 | 63 | A value of -1.0 is on the left side, a value of 1.0 represents the right side. 64 | 65 | Links: [[GetPan]] 66 | 67 | # Method SetPaused:Void(pauseFlag:Bool) 68 | 69 | *Description* 70 | 71 | Pause/resume a sound or a music. 72 | 73 | Links: [[GetPaused]] 74 | 75 | # Method SetPitchRate:Void(channelRate:Float = 1.0) 76 | 77 | *Description* 78 | 79 | Set the rate of a sound. 80 | 81 | *Details* 82 | 83 | The default base note (1.0) is 'A4'. You can use the GetPitchRate("C3") function to determine the rate from a given note. 84 | 85 | Links: [[GetPitchRate]] 86 | 87 | # Method SetVolume:Void(vol:Float = 1.0) 88 | 89 | *Description* 90 | 91 | Set the volume of a sound. Ranges from 0.0 to 1.0. 92 | 93 | Links: [[GetVolume]] 94 | 95 | # Method Stop:Void(c:Int=-1) 96 | 97 | *Description* 98 | 99 | Stop playing the sound. If a channel is given, it will stop that specific sound channel. 100 | 101 | Links: [[Play]] 102 | 103 | -------------------------------------------------------------------------------- /monkeydoc/cftSpriteAtlas.monkeydoc: -------------------------------------------------------------------------------- 1 | # Module cftSpriteAtlas 2 | 3 | The class *ftSpriteAtlas* manages spritesheets inside the fantomEngine. It reduces the call to the device storage by imprting all relevant data into memory. 4 | 5 | # Import fantomEngine 6 | 7 | # Class cftSpriteAtlas.ftSpriteAtlas 8 | 9 | # Method GetAngleOffset:Float(imageName:String) 10 | 11 | *Description* 12 | 13 | Returns the angle offset of an image. 14 | 15 | # Method GetHeight:Int(imageName:String) 16 | 17 | *Description* 18 | 19 | Returns the height of an image. 20 | 21 | # Method GetImage:Image(imageName:String) 22 | 23 | *Description* 24 | 25 | Returns the image with the given name. 26 | 27 | # Method GetImageCount:Int() 28 | 29 | *Description* 30 | 31 | Returns the number of images in the sprite atlas. 32 | 33 | # Method GetImageHeight:Float(imageName:String) 34 | 35 | *Description* 36 | 37 | Returns the height of the subimage with the given name. 38 | 39 | # Method GetImageWidth:Float(imageName:String) 40 | 41 | *Description* 42 | 43 | Returns the width of the subimage with the given name. 44 | 45 | # Method GetRotated:Bool(imageName:String) 46 | 47 | *Description* 48 | 49 | Returns TRUE if the image with the given name is rotated inside the sprite atlas. 50 | 51 | # Method GetWidth:Int(imageName:String) 52 | 53 | *Description* 54 | 55 | Returns the width of an image. 56 | 57 | # Method Load:Void(imgName:String, dataName:String) 58 | 59 | *Description* 60 | 61 | Loads a sprite atlas from the given image and data file name. 62 | 63 | # Method Remove:Void(discard:Bool = False) 64 | 65 | *Description* 66 | 67 | Remove a sprite atlas. Set discard to TRUE if you want the corresponding images to be discarded. 68 | 69 | -------------------------------------------------------------------------------- /monkeydoc/cftTimer.monkeydoc: -------------------------------------------------------------------------------- 1 | # Module cftTimer 2 | 3 | The class *ftTimer* handles ftEngine and ftObject timer objects. 4 | 5 | # Import fantomEngine 6 | 7 | # Class cftTimer.ftTimer 8 | 9 | # Method GetPaused:Bool() 10 | 11 | *Description* 12 | 13 | Returns TRUE if a transition is paused. 14 | 15 | Links: [[SetPaused]] 16 | 17 | # Method RemoveTimer:Void() 18 | 19 | *Description* 20 | 21 | With this method removes the timer. 22 | 23 | # Method SetPaused:Void(pauseFlag:Bool = True) 24 | 25 | *Description* 26 | 27 | With this method you can pause and resume the timer. 28 | 29 | Links: [[GetPaused]], [[Update]] 30 | 31 | -------------------------------------------------------------------------------- /monkeydoc/cftTrans.monkeydoc: -------------------------------------------------------------------------------- 1 | # Module cftTrans 2 | 3 | The class *ftTrans* controls the way an object or layer does a transition. Starting with version 1.49, it utilizes the tween class from the 4 | 5 | 'monkey sample script in bananas/skn3/tweening/tween.monkey 6 | 7 | # Import cftTween 8 | 9 | # Import fantomEngine 10 | 11 | # Class cftTrans.ftTrans 12 | 13 | # Method GetPaused:Bool() 14 | 15 | *Description* 16 | 17 | Returns TRUE if a transition is paused. 18 | 19 | Links: [[SetPaused]] 20 | 21 | # Method SetEase:none(easeType:String="EaseIn") 22 | 23 | *Description* 24 | 25 | Sets the ease type of a transition. 26 | 27 | *Details* 28 | 29 | This command sets the ease type of a transition. The ease type can be: 30 | 31 |

  • EaseIn 32 | 33 |
  • EaseOut 34 | 35 |
  • EaseInOut
36 | 37 | Links: [[SetType]] 38 | 39 | # Method SetPaused:Void(pauseFlag:Bool = True) 40 | 41 | *Description* 42 | 43 | With this method you can pause and resume the transition. 44 | 45 | Links: [[GetPaused]] 46 | 47 | # Method SetType:none(equationType:String="Linear") 48 | 49 | *Description* 50 | 51 | Sets the equation type of a transition. 52 | 53 | *Details* 54 | 55 | This command sets the equation type of a transition. The equation type can be: 56 | 57 |
  • Linear 58 | 59 |
  • Back 60 | 61 |
  • Bounce 62 | 63 |
  • Circ 64 | 65 |
  • Cubic 66 | 67 |
  • Elastic 68 | 69 |
  • Expo 70 | 71 |
  • Quad 72 | 73 |
  • Quart 74 | 75 |
  • Quint 76 | 77 |
  • Sine
78 | 79 | Links: [[SetEase]] 80 | 81 | -------------------------------------------------------------------------------- /monkeydoc/cftVec2D.monkeydoc: -------------------------------------------------------------------------------- 1 | # Module cftVec2D 2 | 3 | The cftVec2D module provides a 2D vector class. 4 | 5 | # Import fantomEngine 6 | 7 | # Class cftVec2D.ftVec2D 8 | 9 | # Method Add:Void(vector:ftVec2D) 10 | 11 | # Method Add:Void(addX:Float, addY:Float) 12 | 13 | # Method Angle:Float(vector:ftVec2D) 14 | 15 | # Method Angle:Float(xPos:Float, yPos:Float) 16 | 17 | # Method Angle:Float() 18 | 19 | # Method Copy:ftVec2D() 20 | 21 | # Method Dot:Float(xPos:Float, yPos:Float) 22 | 23 | # Method Dot:Float(vector:ftVec2D) 24 | 25 | # Method Equals:Bool(vector:ftVec2D) 26 | 27 | # Method Inverse:Void() 28 | 29 | # Method InverseX:Void() 30 | 31 | # Method InverseY:Void() 32 | 33 | # Method Length:Float(vector:ftVec2D) 34 | 35 | # Method Length:Float(xPos:Float, yPos:Float) 36 | 37 | # Method Length:Float() 38 | 39 | # Method Mul:Void(scalar:Float) 40 | 41 | # Method New:none(xp:Float, yp:Float) 42 | 43 | # Method Normalize:Void() 44 | 45 | # Method Perp:Void() 46 | 47 | # Method Set:Void(setX:Float, setY:Float) 48 | 49 | # Method Set:Void(vector:ftVec2D) 50 | 51 | # Method Sub:Void(vector:ftVec2D) 52 | 53 | # Method Sub:Void(subX:Float, subY:Float) 54 | 55 | # Field x:Float 56 | 57 | # Field y:Float 58 | 59 | -------------------------------------------------------------------------------- /monkeydoc/fantomEngine.monkeydoc: -------------------------------------------------------------------------------- 1 | # Module fantomEngine 2 | 3 | The module *fantomEngine* is a 2D game framework which supplies you with huge set of game object related functionalities. 4 | 5 | To use fantomEngine in your game, simply add "Import fantomEngine" at the top of your program. 6 | 7 |

Introduction

8 | fantomEngine is a 2D game framework (module) for Monkey X that was created to give game developers more time to work on the actual game play than on setting up render routines, update process chains and stuff like that. 9 | 10 | With fantomEngine you will write only fractions of the code you did before. 11 |

Website, bug reports and forum support

The most current version of fantomEngine is now hosted at www.fantomgl.com as Google doesn't let someone create new downloads anymore. You can post issues/bug reports at the new support forum. 12 | The forum is also a good place to ask your questions about how to use fantomEngine or make suggestions about needed features. 13 |

Features

fantomEngine currently supports the following features: 14 |
  • Various objects like images, tile maps, graphic primitives, sounds, collision zones and layers. 15 |
  • Automatic processes to create, update and render objects. 16 |
  • Callback methods which are called during the handling of an object, layer, timer and transitions. 17 |
  • Layer transitions with callback methods. 18 |
  • Object transitions for position, rotation, scaling and alpha values with callback methods. 19 |
  • Several equation and ease types for object and layer transitions. 20 |
  • Object timers with callback methods. 21 |
  • Different collision methods with callback methods. 22 |
  • Touch input handling with callback methods. 23 |
  • Organize your objects in layers. 24 |
  • Automatic content scaling via providing a virtual canvas setup. 25 |
  • Simple high-score list loading, saving and updating. 26 |
  • Simple sound loading which handles the proper file extension depending on the chosen platform. 27 |
  • Support for bitmap font text objects which load EzGUI font descriptions. 28 |
  • Build-in frames per second calculator. 29 |
  • Extensive handling methods for the engine's objects. 30 |
  • Simple camera support which you can move around to render parts of your scenery. 31 |
  • Support for texture maps (atlas) created by the tool TexturePacker. 32 |
  • Support for tile maps created by the tool Tiled. 33 |
  • Engine time scaling supporting object updates, timers and transitions. 34 |
  • Automatic swipe gesture detection with event method. 35 |
  • Path/Waypoint handling. Let your objects follow them. 36 |
  • A* pathfinding und user definable grids of nodes. It doesn't have to be a grid of squares! 37 |
  • Easy integration of Box2D powered physics including ray casting. Physics definition created by the tool PhysicsEditor are supported too. 38 |
  • Localize your game easily with easy support of multiple languages. 39 |
  • Support different key maps for different controllers or user definitions. 40 |
  • Embedded objects inside a Tiled map will be stored and are accessable. 41 |
  • Easy scene/room management. 42 |
  • Objects can be composed of several single images. 43 |
  • Automatic object pooling. 44 |
  • Custom GUI elements
45 | # Import brl.pool 46 | 47 | # Import fantomEngine.cftAStar 48 | 49 | # Import fantomEngine.cftBox2D 50 | 51 | # Import fantomEngine.cftEngine 52 | 53 | # Import fantomEngine.cftFont 54 | 55 | # Import fantomEngine.cftFunctions 56 | 57 | # Import fantomEngine.cftGui 58 | 59 | # Import fantomEngine.cftHighscore 60 | 61 | # Import fantomEngine.cftImageMng 62 | 63 | # Import fantomEngine.cftKeyMapping 64 | 65 | # Import fantomEngine.cftLayer 66 | 67 | # Import fantomEngine.cftLocalization 68 | 69 | # Import fantomEngine.cftMisc 70 | 71 | # Import fantomEngine.cftObjAnimMng 72 | 73 | # Import fantomEngine.cftObject 74 | 75 | # Import fantomEngine.cftRGBA 76 | 77 | # Import fantomEngine.cftScene 78 | 79 | # Import fantomEngine.cftSound 80 | 81 | # Import fantomEngine.cftSpriteAtlas 82 | 83 | # Import fantomEngine.cftSwipe 84 | 85 | # Import fantomEngine.cftTileMap 86 | 87 | # Import fantomEngine.cftTimer 88 | 89 | # Import fantomEngine.cftTrans 90 | 91 | # Import fantomEngine.cftVec2D 92 | 93 | # Import fantomEngine.cftWaypoints 94 | 95 | # Import json 96 | 97 | # Import mojo 98 | 99 | -------------------------------------------------------------------------------- /native/fantomengine.android.java: -------------------------------------------------------------------------------- 1 | import android.os.Build; 2 | 3 | class fantomengine 4 | { 5 | static String DeviceName() 6 | { 7 | return android.os.Build.MODEL; 8 | } 9 | 10 | static String Hardware() 11 | { 12 | return android.os.Build.HARDWARE; 13 | } 14 | 15 | static String User() 16 | { 17 | return android.os.Build.USER; 18 | } 19 | 20 | static String Product() 21 | { 22 | return android.os.Build.PRODUCT; 23 | } 24 | 25 | static String Serial() 26 | { 27 | return android.os.Build.SERIAL; 28 | } 29 | 30 | static String GetBrowserName() 31 | { 32 | return "---"; 33 | } 34 | 35 | static String GetBrowserVersion() 36 | { 37 | return "---"; 38 | } 39 | 40 | static String GetBrowserPlatform() 41 | { 42 | return "---"; 43 | } 44 | } -------------------------------------------------------------------------------- /native/fantomengine.ios.cpp: -------------------------------------------------------------------------------- 1 | class fantomengine 2 | { 3 | public: 4 | 5 | static String DeviceName() 6 | { 7 | NSString * localizedModel = [[UIDevice currentDevice] localizedModel]; 8 | return [localizedModel UTF8String]; 9 | } 10 | static String Hardware() 11 | { 12 | NSString *model = [[UIDevice currentDevice] model]; 13 | return [model UTF8String]; 14 | } 15 | 16 | static String User() 17 | { 18 | NSString * name = [[UIDevice currentDevice] name]; 19 | return [name UTF8String]; 20 | } 21 | 22 | static String Product() 23 | { 24 | return '-' ; 25 | } 26 | 27 | static String Serial() 28 | { 29 | NSString *uniqueIdentifier = [[UIDevice currentDevice] uniqueIdentifier]; 30 | return [uniqueIdentifier UTF8String]; 31 | } 32 | 33 | static String GetBrowserName() 34 | { 35 | return '-' ; 36 | } 37 | 38 | static String GetBrowserVersion() 39 | { 40 | return '-' ; 41 | } 42 | 43 | static String GetBrowserPlatform() 44 | { 45 | return '-' ; 46 | } 47 | 48 | }; 49 | --------------------------------------------------------------------------------