User Tools

Site Tools


en:guides:beginners:platforms_and_texture_repeating

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:guides:beginners:platforms_and_texture_repeating [2018/02/13 20:47 (7 years ago)] – ↷ Page moved from guides:beginners:platforms_and_texture_repeating to en:guides:beginners:platforms_and_texture_repeating iarwainen:guides:beginners:platforms_and_texture_repeating [2024/11/17 03:22 (5 months ago)] (current) sausage
Line 1: Line 1:
 ====== Part 8 – Platforms and Texture Repeating ====== ====== Part 8 – Platforms and Texture Repeating ======
  
-Our playfield will contain a number of platforms. What have we got in the current asset folders that would do for a platform?+Our playfield will contain a number of platforms. What have we got in the current tutorial asset folders over  in the Orx project that would do for a platform?
  
 {{ :guides:beginners:box.png?nolink&60 |}} {{ :guides:beginners:box.png?nolink&60 |}}
  
-box.png. That'll do nicely. We'll repeat this object in a line to produce a platform.+''box.png'' from ''orx/tutorial/data/object''. That'll do nicely. Copy this file into our ''data/texture'' folder. 
 + 
 +We'll eventually repeat this object in a line to produce a platform.
  
 Start off with a single platform object: Start off with a single platform object:
Line 15: Line 17:
 [PlatformObject] [PlatformObject]
 Graphic  = PlatformGraphic Graphic  = PlatformGraphic
-Position = (20470, 0)+Position = (-380170, 0)
 Scale    = 2 Scale    = 2
 </code> </code>
Line 21: Line 23:
 And create it inside the Init() function with: And create it inside the Init() function with:
  
-<code=ini>+<code=ini [highlight_lines_extra="2"]> 
 +orxObject_CreateFromConfig("HeroObject");
 orxObject_CreateFromConfig("PlatformObject"); orxObject_CreateFromConfig("PlatformObject");
 </code> </code>
Line 29: Line 32:
 {{:guides:beginners:beginners-21-box-object.png?nolink|}} {{:guides:beginners:beginners-21-box-object.png?nolink|}}
  
-Great. Next, the platform needs to be stretched out so that it acts like a platform and not just a simple box. You can do this by changing the scale property:+Great. Next, the platform needs to be stretched out so that it acts like a platform and not just a simple box. You can do this by changing the ''Scale'' property:
  
-<code=ini>+<code=ini [highlight_lines_extra="4"]>
 [PlatformObject] [PlatformObject]
 Graphic  = PlatformGraphic Graphic  = PlatformGraphic
-Position = (20470, 0)+Position = (-380170, 0)
 Scale    = (40, 2, 0) Scale    = (40, 2, 0)
 </code> </code>
Line 48: Line 51:
 We also need the Repeat property, so that the texture will repeat within the object: We also need the Repeat property, so that the texture will repeat within the object:
  
-<code=ini>+<code=ini [highlight_lines_extra="5"]>
 [PlatformObject] [PlatformObject]
 Graphic  = PlatformGraphic Graphic  = PlatformGraphic
-Position = (20470, 0)+Position = (-380170, 0)
 Scale    = (40, 2, 0) Scale    = (40, 2, 0)
 Repeat   = (20, 1, 0) Repeat   = (20, 1, 0)
Line 66: Line 69:
 Let's move the platform to the bottom of the screen and extend it to the whole screen width: Let's move the platform to the bottom of the screen and extend it to the whole screen width:
  
-<code=ini>+<code=ini [highlight_lines_extra="3,4,5"]>
 [PlatformObject] [PlatformObject]
 Graphic  = PlatformGraphic Graphic  = PlatformGraphic
-Position = (0570, 0)+Position = (-400270, 0)
 Scale    = (54, 2, 0) Scale    = (54, 2, 0)
 Repeat   = (27, 1, 0) Repeat   = (27, 1, 0)
Line 76: Line 79:
 We can use this as a template to create many platforms. But rather than create a few platforms in code, it would be much easier to create a single empty parent object with a few child objects under it. We can use this as a template to create many platforms. But rather than create a few platforms in code, it would be much easier to create a single empty parent object with a few child objects under it.
  
-Start by making the parent object called Scene to contain all the platform objects (and later other objects too):+Start by re-using the Scene object as a parent to contain all the platform objects (and later other objects too):
  
-<code=ini>+<code=ini [highlight_lines_extra="2"]>
 [Scene] [Scene]
 ChildList = PlatformObject # MiddlePlatformObject # TopLeftPlatformObject #TopPlatformObject #TopRightPlatformObject ChildList = PlatformObject # MiddlePlatformObject # TopLeftPlatformObject #TopPlatformObject #TopRightPlatformObject
 </code> </code>
  
-Anything added to a ChildList will become a child under the object, and will move with the parent. Its co-ordinates will be local under the parent.+Anything added to a ''ChildList'' will become a child under the object, and will move with the parent. Its co-ordinates will be local under the parent.
  
-Notice that PlatformObject is the only thing in the list that exists so far. Let's create others based on the settings of PlatformObject:+Notice that the ''PlatformObject'' is the only thing in the list that exists so far. Let's create others based on the settings of ''PlatformObject'':
  
 <code=ini> <code=ini>
 [MiddlePlatformObject@PlatformObject] [MiddlePlatformObject@PlatformObject]
-Position = (250450, 0) +Position = (-150150, 0) 
-Scale = (30, 2, 0) +Scale    = (30, 2, 0) 
-Repeat = (15, 1, 0)+Repeat   = (15, 1, 0)
  
 [TopLeftPlatformObject@PlatformObject] [TopLeftPlatformObject@PlatformObject]
-Position = (0320, 0) +Position = (-40020, 0) 
-Scale = (14, 2, 0) +Scale    = (14, 2, 0) 
-Repeat = (7, 1, 0)+Repeat   = (7, 1, 0)
  
 [TopPlatformObject@TopLeftPlatformObject] [TopPlatformObject@TopLeftPlatformObject]
-Position = (300200, 0)+Position = (-100-100, 0)
  
 [TopRightPlatformObject@TopLeftPlatformObject] [TopRightPlatformObject@TopLeftPlatformObject]
-Position = (60090, 0)+Position = (200-210, 0)
 </code> </code>
  
-A quick explanation of the above syntax: MiddlePlatformObject and TopLeftPlatformObject inherit all four properties from PlatformObject and overrides three of them. TopPlatformObject and TopRightPlatformObject inherit properties from TopLeftPlatformObject, and the fourth property indirectly from PlatformObject.+A quick explanation of the above syntax: ''MiddlePlatformObject'' and ''TopLeftPlatformObject'' inherit all four properties from ''PlatformObject'' and overrides three of them. ''TopPlatformObject'' and ''TopRightPlatformObject'' inherit properties from ''TopLeftPlatformObject'', and the fourth property indirectly from ''PlatformObject''.
  
-This is really to save configuration, and to make things easier to change rather than copy and pasting the same details over and over.+This is really to save on configuration, to be extensible, and to make things easier to change rather than copy and pasting the same details over and over.
  
 Next change the code in the Init() function to create "Scene" instead of "PlatformObject": Next change the code in the Init() function to create "Scene" instead of "PlatformObject":
  
-<code=cpp>+<code=cpp [highlight_lines_extra="2"]> 
 +orxObject_CreateFromConfig("HeroObject");
 orxObject_CreateFromConfig("Scene"); orxObject_CreateFromConfig("Scene");
 </code> </code>
Line 125: Line 129:
 ---- ----
  
-Next, [[guides:beginners:physics|Part 9 - Physics]].+Next, [[en:guides:beginners:physics|Part 9 - Physics]].
  
-{{section>guides:beginners:toc&noheader&nofooter&noeditbutton}}+{{section>en:guides:beginners:toc&noheader&nofooter&noeditbutton}}
en/guides/beginners/platforms_and_texture_repeating.1518583672.txt.gz · Last modified: 2018/02/14 00:47 (7 years ago) (external edit)