<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.gideros.rocks/index.php?action=history&amp;feed=atom&amp;title=Tuto_Gideros_Game_Template1_Part_8_Player</id>
	<title>Tuto Gideros Game Template1 Part 8 Player - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.gideros.rocks/index.php?action=history&amp;feed=atom&amp;title=Tuto_Gideros_Game_Template1_Part_8_Player"/>
	<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Tuto_Gideros_Game_Template1_Part_8_Player&amp;action=history"/>
	<updated>2026-11-18T03:01:25Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Tuto_Gideros_Game_Template1_Part_8_Player&amp;diff=24095&amp;oldid=prev</id>
		<title>MoKaLux at 00:43, 25 November 2024</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Tuto_Gideros_Game_Template1_Part_8_Player&amp;diff=24095&amp;oldid=prev"/>
		<updated>2024-11-25T00:43:10Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 00:43, 25 November 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l81&quot;&gt;Line 81:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 81:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;I hope this tutorial was useful and will help you on your journey making great games using Gideros Studio ;-)&amp;#039;&amp;#039;&amp;#039;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;I hope this tutorial was useful and will help you on your journey making great games using Gideros Studio ;-)&amp;#039;&amp;#039;&amp;#039;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;the &lt;/del&gt;Project file ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;The &lt;/ins&gt;Project file ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;[[Media:GIDEROS_GAME_TEMPLATE1.zip]]&amp;#039;&amp;#039;&amp;#039; &amp;#039;&amp;#039;&amp;#039;(tip: right click and save link as)&amp;#039;&amp;#039;&amp;#039;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;[[Media:GIDEROS_GAME_TEMPLATE1.zip]]&amp;#039;&amp;#039;&amp;#039; &amp;#039;&amp;#039;&amp;#039;(tip: right click and save link as)&amp;#039;&amp;#039;&amp;#039;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Tuto_Gideros_Game_Template1_Part_8_Player&amp;diff=23872&amp;oldid=prev</id>
		<title>MoKaLux: Created page with &quot;__TOC__ == a Player == We test our Gideros Game Template1 and add a player you can control with the keyboard.   &#039;&#039;&#039;Note: this is for testing purposes only&#039;&#039;&#039;  I didn&#039;t really...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Tuto_Gideros_Game_Template1_Part_8_Player&amp;diff=23872&amp;oldid=prev"/>
		<updated>2024-10-27T19:01:31Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;__TOC__ == a Player == We test our Gideros Game Template1 and add a player you can control with the keyboard.   &amp;#039;&amp;#039;&amp;#039;Note: this is for testing purposes only&amp;#039;&amp;#039;&amp;#039;  I didn&amp;#039;t really...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;__TOC__&lt;br /&gt;
== a Player ==&lt;br /&gt;
We test our Gideros Game Template1 and add a player you can control with the keyboard.&lt;br /&gt;
&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;Note: this is for testing purposes only&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
I didn&amp;#039;t really know where to put the code so I chose to create a file called &amp;quot;&amp;#039;&amp;#039;player1.lua&amp;#039;&amp;#039;&amp;quot; in the &amp;#039;&amp;#039;&amp;#039;gfx&amp;#039;&amp;#039;&amp;#039; folder.&lt;br /&gt;
&lt;br /&gt;
The &amp;#039;&amp;#039;&amp;#039;Player&amp;#039;&amp;#039;&amp;#039; Class will mainly consist of:&lt;br /&gt;
* a Sprite (a Pixel)&lt;br /&gt;
* some vars&lt;br /&gt;
* controlling the player using the keyboard&lt;br /&gt;
&lt;br /&gt;
The code:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
Player1 = Core.class(Sprite)&lt;br /&gt;
&lt;br /&gt;
function Player1:init()&lt;br /&gt;
	self.sprite = Pixel.new(math.random(0xffffff), 1, 32, 64)&lt;br /&gt;
	self.sprite:setAnchorPoint(0.5, 0.5)&lt;br /&gt;
	-- some vars&lt;br /&gt;
	self.x = 0&lt;br /&gt;
	self.y = 0&lt;br /&gt;
	self.speed = 32*6&lt;br /&gt;
	self.vx = 0&lt;br /&gt;
	self.vy = 0&lt;br /&gt;
	self.sx = 1&lt;br /&gt;
	self.sy = 1&lt;br /&gt;
	self.w = self.sprite:getWidth() * self.sx&lt;br /&gt;
	self.h = self.sprite:getHeight() * self.sy&lt;br /&gt;
	self.flip = 1&lt;br /&gt;
	-- position&lt;br /&gt;
	self.sprite:setPosition(self.x, self.y)&lt;br /&gt;
	-- order&lt;br /&gt;
	self:addChild(self.sprite)&lt;br /&gt;
	-- let&amp;#039;s go&lt;br /&gt;
	self:myKeysPressed()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- keys handler&lt;br /&gt;
function Player1:myKeysPressed()&lt;br /&gt;
	self:addEventListener(Event.KEY_DOWN, function(e)&lt;br /&gt;
		-- movements&lt;br /&gt;
		if e.keyCode == KeyCode.LEFT or e.keyCode == g_keyleft then self.isleft = true end&lt;br /&gt;
		if e.keyCode == KeyCode.RIGHT or e.keyCode == g_keyright then self.isright = true end&lt;br /&gt;
		if e.keyCode == KeyCode.UP or e.keyCode == g_keyup then self.isup = true end&lt;br /&gt;
		if e.keyCode == KeyCode.DOWN or e.keyCode == g_keydown then self.isdown = true end&lt;br /&gt;
		-- actions&lt;br /&gt;
		if e.keyCode == g_keyaction1 then self.isactionpunch1 = true end&lt;br /&gt;
		if e.keyCode == g_keyaction2 then self.isactionpunch2 = true end&lt;br /&gt;
		if e.keyCode == g_keyaction3 then self.isactionpunch3 = true end&lt;br /&gt;
	end)&lt;br /&gt;
	self:addEventListener(Event.KEY_UP, function(e)&lt;br /&gt;
		-- movements&lt;br /&gt;
		if e.keyCode == KeyCode.LEFT or e.keyCode == g_keyleft then self.isleft = false end&lt;br /&gt;
		if e.keyCode == KeyCode.RIGHT or e.keyCode == g_keyright then self.isright = false end&lt;br /&gt;
		if e.keyCode == KeyCode.UP or e.keyCode == g_keyup then self.isup = false end&lt;br /&gt;
		if e.keyCode == KeyCode.DOWN or e.keyCode == g_keydown then self.isdown = false end&lt;br /&gt;
		-- actions&lt;br /&gt;
		if e.keyCode == g_keyaction1 then self.isactionpunch1 = false end&lt;br /&gt;
		if e.keyCode == g_keyaction2 then self.isactionpunch2 = false end&lt;br /&gt;
		if e.keyCode == g_keyaction3 then self.isactionpunch3 = false end&lt;br /&gt;
	end)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code comments ==&lt;br /&gt;
In init we make our player1 be a Pixel.&lt;br /&gt;
&lt;br /&gt;
We set various variables which we will update in the &amp;#039;&amp;#039;&amp;#039;Game&amp;#039;&amp;#039;&amp;#039; scene (&amp;#039;&amp;#039;&amp;#039;LevelX&amp;#039;&amp;#039;&amp;#039;) to reflect the user input.&lt;br /&gt;
&lt;br /&gt;
=== keys handler ===&lt;br /&gt;
This is where the key remapping system shines :-)&lt;br /&gt;
&lt;br /&gt;
== Next? ==&lt;br /&gt;
Well that&amp;#039;s it for this Gideros Game Template1 tutorial.&lt;br /&gt;
&lt;br /&gt;
This is now yours to use/modify (add scenes, ...).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;I hope this tutorial was useful and will help you on your journey making great games using Gideros Studio ;-)&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
== the Project file ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;[[Media:GIDEROS_GAME_TEMPLATE1.zip]]&amp;#039;&amp;#039;&amp;#039; &amp;#039;&amp;#039;&amp;#039;(tip: right click and save link as)&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Prev.: [[Tuto Gideros Game Template1 Part 7 Game]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;END&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;[[Tutorial - Gideros Game Template1]]&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
{{GIDEROS IMPORTANT LINKS}}&lt;/div&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
</feed>