Libraries.Curriculum.TurtleProgram.TurtleGame Documentation
Inherits from: Libraries.Language.Object, Libraries.Game.Game
Actions Documentation
Add(Libraries.Game.Graphics.DirectionalLight light)
This action will add a DirectionalLight to the currently active Layer3D.
Parameters
- Libraries.Game.Graphics.DirectionalLight: The light to add to the currently active Layer3D.
Example
use Libraries.Game.Game
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.AmbientLight
use Libraries.Game.Graphics.DirectionalLight
class Main is Game
action Main
StartGame()
end
action CreateGame
Color color
Model box
box:LoadBox(2, 2, 2, color:Teal())
Add(box)
AmbientLight ambient
ambient:SetColor(0.4, 0.4, 0.4, 1)
SetAmbientLight(ambient)
DirectionalLight light
light:SetColor(0.8, 0.8, 0.8, 1)
light:SetDirection(1, -2, 1)
Add(light)
end
end
Add(Libraries.Interface.Item2D item)
The Add action will add an item to the Game. More specifically, the item will be added to the current default Layer2D. This will make the game handle the item for many tasks. For example, adding a Drawable will make it draw on the screen.
Parameters
- Libraries.Interface.Item2D: The item to be added to the current default Layer2D.
Example
use Libraries.Game.Game
use Libraries.Game.Graphics.Drawable
class Main is Game
Drawable bunny
action Main
StartGame()
end
action CreateGame
bunny:Load("Images/Rabbit.png")
Add(bunny)
end
end
Add(Libraries.Game.Graphics.PointLight light)
This action will add a PointLight to the currently active Layer3D.
Parameters
- Libraries.Game.Graphics.PointLight: The light to add to the currently active Layer3D.
Example
use Libraries.Game.Game
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.AmbientLight
use Libraries.Game.Graphics.PointLight
class Main is Game
action Main
StartGame()
end
action CreateGame
Color color
Model box
box:LoadBox(2, 2, 2, color:Teal())
Add(box)
AmbientLight ambient
ambient:SetColor(0.4, 0.4, 0.4, 1)
SetAmbientLight(ambient)
PointLight light
light:SetColor(0.8, 0.8, 0.8, 1)
light:SetPosition(4, 3, -2)
light:SetIntensity(30)
Add(light)
end
end
Add(Libraries.Interface.Item3D item)
The Add action will add an item to the Game. More specifically, the item will be added to the current default Layer3D. This will make the game handle the item for many tasks. For example, adding a Model will make it draw on the screen.
Parameters
- Libraries.Interface.Item3D: The item to be added to the current default Layer3D.
Example
use Libraries.Game.Game
use Libraries.Game.Graphics.Model
class Main is Game
Model car
action Main
StartGame()
end
action CreateGame
car:Load("sedan.g3db")
Add(car)
end
end
AddCollisionListener(Libraries.Interface.Events.CollisionListener2D listener)
Adds a collision listener to the game that will listen for collisions between 2D game objects that have been flagged as collidable. This listener can respond to collisions by implementing the BeginCollision and FinishCollision actions.
Parameters
Example
use Libraries.Game.Game
use Libraries.Interface.Item2D
use Libraries.Interface.Events.CollisionListener2D
use Libraries.Interface.Events.CollisionEvent2D
class Main is Game, CollisionListener2D
Item2D item1
Item2D item2
action Main
StartGame()
end
action CreateGame
AddCollisionListener(me)
item1:SetCollidable(true)
item2:SetCollidable(true)
end
action BeginCollision(CollisionEvent2D event)
end
action FinishCollision(CollisionEvent3D event)
end
end
AddCollisionListener(Libraries.Interface.Events.CollisionListener3D listener)
Adds a collision listener to the game that will listen for collisions between 3D game objects that have been flagged as collidable. This listener can respond to collisions by implementing the BeginCollision and FinishCollision actions.
Parameters
Example
use Libraries.Game.Game
use Libraries.Interface.Item3D
use Libraries.Interface.Events.CollisionListener3D
use Libraries.Interface.Events.CollisionEvent3D
class Main is Game, CollisionListener3D
Item3D item1
Item3D item2
action Main
StartGame()
end
action CreateGame
AddCollisionListener(me)
item1:SetCollidable(true)
item2:SetCollidable(true)
end
action BeginCollision(CollisionEvent3D event)
end
action FinishCollision(CollisionEvent3D event)
end
end
AddControlActivationListener(Libraries.Interface.Events.ControlActivationListener listener)
AddFocusListener(Libraries.Interface.Events.FocusListener listener)
This action adds a FocusListener to the Game. Whenever the focus changes, the FocusListener will be informed via a FocusEvent.
Parameters
- Libraries.Interface.Events.FocusListener: The FocusListener to add to the Game.
AddGestureListener(Libraries.Interface.Events.GestureListener listener)
This action adds a GestureListener to the Game. The gesture listener will be notified when the user performs a gesture on mobile devices, so long as the event is not handled by any items in the layers.
Parameters
- Libraries.Interface.Events.GestureListener: The GestureListener to add to the Game.
Example
use Libraries.Game.Game
use Libraries.Interface.Events.GestureListener
class Main is Game
GestureListener listener
action Main
StartGame()
end
action CreateGame
AddGestureListener(listener)
end
end
AddInputTable(Libraries.Game.InputTable table)
This action adds an InputTable to the Game. If at any point the currently focused Item has an input group that matches the identifier of the table, the table will be used to trigger Behaviors.
Parameters
AddKeyboardListener(Libraries.Interface.Events.KeyboardListener listener)
This action adds a KeyboardListener to the Game. The listener will be notified of keys being pressed and released.
Parameters
- Libraries.Interface.Events.KeyboardListener: The KeyboardListener to add to the Game.
Example
use Libraries.Game.Game
use Libraries.Interface.Events.KeyboardListener
class Main is Game
KeyboardListener listener
action Main
StartGame()
end
action CreateGame
AddKeyboardListener(listener)
end
end
AddLayer(integer index, Libraries.Game.Layer layer)
This action will add the given Layer to the Game at the given index. Layers are handled (e.g. updated, drawn, etc.) in the order they're added, starting at index 0 with additional layers placed at higher indices.
Parameters
- integer index: The index to place the Layer at.
- Libraries.Game.Layer: The Layer to be added to the Game. use Libraries.Game.Game use Libraries.Game.Layer2D class Main is Game action Main StartGame() end action CreateGame // This will add the layer at index 0, making it the first layer drawn. Layer2D layer AddLayer(0, layer) end action Update(number seconds) end end
AddLayer(Libraries.Game.Layer layer)
This action will add a new Layer to the Game. It will be added on top of all other layers currently in the game.
Parameters
- Libraries.Game.Layer: The Layer to be added to the Game. use Libraries.Game.Game use Libraries.Game.Layer2D class Main is Game action Main StartGame() end action CreateGame Layer2D layer AddLayer(layer) end action Update(number seconds) end end