Difference between revisions of "Player Functions"
Line 50: | Line 50: | ||
x, y, bright = Game.GetAPlayerPosition(0) | x, y, bright = Game.GetAPlayerPosition(0) | ||
Game.Message("Player0 position is ("..x..","..y..")") | Game.Message("Player0 position is ("..x..","..y..")") | ||
+ | return true | ||
+ | end | ||
+ | |||
+ | |||
+ | == KillPlayer() == | ||
+ | [require Xmoto >= 0.2.1] | ||
+ | === Explanation === | ||
+ | If you call this function, the players die. It's interesting if you want the players be killed by an enemy for example. | ||
+ | |||
+ | === Script example === | ||
+ | In the following example, the player will die when he will enter in the zone Zone0. | ||
+ | |||
+ | Zone0 = {} | ||
+ | |||
+ | function Zone0.OnEnter() | ||
+ | Game.KillPlayer() | ||
+ | end | ||
+ | |||
+ | |||
+ | == KillAPlayer(player) == | ||
+ | [require Xmoto >= 0.3.0] | ||
+ | === Explanation === | ||
+ | If you call this function, a player dies. It's interesting if you want the player be killed by an enemy for example. | ||
+ | |||
+ | === Script example === | ||
+ | function OnLoad() | ||
+ | Game.KillAPlayer(0) | ||
+ | return true | ||
+ | end | ||
+ | |||
+ | |||
+ | == WinPlayer() == | ||
+ | [require Xmoto >= 0.2.1] | ||
+ | === Explanation === | ||
+ | If you call this function, all players win the game (even if there are remaining strawberries). | ||
+ | |||
+ | === Script example === | ||
+ | In the following example, the player win on entering in the zone Zone0. | ||
+ | |||
+ | Zone0 = {} | ||
+ | |||
+ | function Zone0.OnEnter() | ||
+ | Game.WinPlayer() | ||
+ | end | ||
+ | |||
+ | |||
+ | == WinAPlayer(player) == | ||
+ | [require Xmoto >= 0.3.0] | ||
+ | === Explanation === | ||
+ | If you call this function, a player wins the game (even if there are remaining strawberries). | ||
+ | |||
+ | === Script example === | ||
+ | function OnLoad() | ||
+ | Game.WinAPlayer(0) | ||
return true | return true | ||
end | end |
Revision as of 12:25, 14 March 2008
Contents
SetPlayerPosition(x, y, bRight)
Explanation
Set the position and direction of the players in the game. bRight can be 0 or 1.
Script example
The example teleports the playerq each time one enters the zone.
Zone0 = {} function Zone0.OnEnter() Game.SetPlayerPosition(5, 0, 1) end
SetAPlayerPosition(x, y, bRight, player)
Explanation
Set the position and direction of the player in the game. bRight can be 0 or 1.
Script example
The example show how to teleport the player 0 at start of the level to the position (20, 5)
function OnLoad() Game.SetAPlayerPosition(20, 5, 1, 0) return true end
GetPlayerPosition()
Explanation
Return the triplet (x, y, bRight) which give the position of the player 0 in the game.
Script example
This example make the player unable to get the strawberry ;-)
function Tick() x, y, bright = Game.GetPlayerPosition() if x > 18 then Game.SetPlayerPosition(5, 0, 1) end return true end
GetAPlayerPosition(player)
[require Xmoto >= 0.3.0]
Explanation
Return the triplet (x, y, bRight) which give the position of a player in the game.
Script example
function OnLoad() x, y, bright = Game.GetAPlayerPosition(0) Game.Message("Player0 position is ("..x..","..y..")") return true end
KillPlayer()
[require Xmoto >= 0.2.1]
Explanation
If you call this function, the players die. It's interesting if you want the players be killed by an enemy for example.
Script example
In the following example, the player will die when he will enter in the zone Zone0.
Zone0 = {} function Zone0.OnEnter() Game.KillPlayer() end
KillAPlayer(player)
[require Xmoto >= 0.3.0]
Explanation
If you call this function, a player dies. It's interesting if you want the player be killed by an enemy for example.
Script example
function OnLoad() Game.KillAPlayer(0) return true end
WinPlayer()
[require Xmoto >= 0.2.1]
Explanation
If you call this function, all players win the game (even if there are remaining strawberries).
Script example
In the following example, the player win on entering in the zone Zone0.
Zone0 = {} function Zone0.OnEnter() Game.WinPlayer() end
WinAPlayer(player)
[require Xmoto >= 0.3.0]
Explanation
If you call this function, a player wins the game (even if there are remaining strawberries).
Script example
function OnLoad() Game.WinAPlayer(0) return true end