Changeset 6538 for 2015/27/ohjaajat
- Timestamp:
- 2015-06-29 16:51:35 (6 years ago)
- Location:
- 2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/LevelCreation.cs
r6536 r6538 7 7 public partial class TheLegendOfGabriel : PhysicsGame 8 8 { 9 /// <summary> 10 /// Luo pelaajan. 11 /// </summary> 12 void CreatePlayer(Vector position) 13 { 14 player = new Creature(TILE_SIZE, TILE_SIZE); 15 player.MovementSpeed = 2300; 16 player.Position = position; 17 Add(player); 18 } 19 9 20 /// <summary> 10 21 /// Luo kentän .tmx tiedostosta. … … 21 32 22 33 /// <summary> 23 /// Maassa oleva perus tiili , jonka läpi voi kävellä.34 /// Maassa oleva perus tiili. 24 35 /// </summary> 25 void CreateBaseTile(Vector position, double width, double height, Image image, string layerName )36 void CreateBaseTile(Vector position, double width, double height, Image image, string layerName, Dictionary<string, string> properties) 26 37 { 27 CreateBasicTile(position, width, height, image, -1 );38 CreateBasicTile(position, width, height, image, -1, properties); 28 39 } 29 40 … … 31 42 /// Pelaajan päällä näkyvä perus tiili. 32 43 /// </summary> 33 void CreateForegroundTile(Vector position, double width, double height, Image image, string layerName )44 void CreateForegroundTile(Vector position, double width, double height, Image image, string layerName, Dictionary<string, string> properties) 34 45 { 35 CreateBasicTile(position, width, height, image, 1 );46 CreateBasicTile(position, width, height, image, 1, properties); 36 47 } 37 48 38 49 /// <summary> 39 /// Luo tavallisen tiilen jonka läpi voi kävellä.50 /// Luo tavallisen tiilen. 40 51 /// </summary> 41 void CreateBasicTile(Vector position, double width, double height, Image image, int layer )52 void CreateBasicTile(Vector position, double width, double height, Image image, int layer, Dictionary<string, string> properties) 42 53 { 43 var tile = new GameObject(width, height);54 var tile = properties.ContainsKey("collide")? new PhysicsObject(width, height) : new GameObject(width, height); 44 55 tile.Image = image; 45 56 tile.Position = position; -
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel.cs
r6536 r6538 7 7 using Jypeli.Widgets; 8 8 9 class Creature : PhysicsObject 10 { 11 public double MovementSpeed { get; set; } 12 13 public Creature(double width, double height) 14 : base(width, height) 15 { 16 LinearDamping = 0.5; 17 } 18 19 public void Move(Direction direction) 20 { 21 Push(direction.GetVector() * MovementSpeed); 22 } 23 } 24 9 25 public partial class TheLegendOfGabriel : PhysicsGame 10 26 { 27 public const int TILE_SIZE = 20; 28 29 private Creature player; 30 11 31 public override void Begin() 12 32 { … … 18 38 { 19 39 ClearAll(); 20 CreateLevel("testlevel"); 40 CreateLevel("testlevel2"); 41 CreatePlayer(new Vector(30, -30)); 21 42 SetControls(); 22 43 Camera.ZoomToLevel(); … … 25 46 void SetControls() 26 47 { 48 Keyboard.Listen(Key.Left, ButtonState.Down, player.Move, null, Direction.Left); 49 Keyboard.Listen(Key.Right, ButtonState.Down, player.Move, null, Direction.Right); 50 Keyboard.Listen(Key.Up, ButtonState.Down, player.Move, null, Direction.Up); 51 Keyboard.Listen(Key.Down, ButtonState.Down, player.Move, null, Direction.Down); 52 27 53 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, null); 28 54 } -
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabriel/TiledTileMap.cs
r6536 r6538 11 11 { 12 12 public delegate void ObjectMethod( 13 Vector position, double width, double height, Angle angle, Shape shape, 14 Dictionary<string, string> properties); 13 Vector position, double width, double height, Angle angle, Shape shape, Dictionary<string, string> properties); 15 14 16 public delegate void TileMethod(Vector position, double width, double height, Image image, string layerName); 15 public delegate void TileMethod( 16 Vector position, double width, double height, Image image, string layerName, Dictionary<string, string> properties); 17 17 18 18 private readonly Dictionary<string, ObjectMethod> objectLegend = new Dictionary<string, ObjectMethod>(); … … 82 82 double realX = game.Level.Left + (tile.X * tileWidth) + (tileWidth / 2); 83 83 double realY = game.Level.Top - (tile.Y * tileHeight) - (tileHeight / 2); 84 method(new Vector(realX, realY), tileWidth, tileHeight, tileImages[tileIndex], layer.Name); 84 Dictionary<string,string> props = level.Tilesets[0].Tiles.Where(t => level.Tilesets[0].FirstGid + t.Id == tile.Gid).Select(t => t.Properties).FirstOrDefault(); 85 props = props ?? new Dictionary<string, string>(); 86 method(new Vector(realX, realY), tileWidth, tileHeight, tileImages[tileIndex], layer.Name, props); 85 87 } 86 88 } -
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabrielContent/LegendOfGabrielTileset.tsx
r6536 r6538 2 2 <tileset name="LegendOfGabrielTileset" tilewidth="20" tileheight="20"> 3 3 <image source="tileset.png" width="200" height="200"/> 4 <tile id="2"> 5 <properties> 6 <property name="collide" value="true"/> 7 </properties> 8 </tile> 4 9 </tileset> -
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabrielContent/TheLegendOfGabrielContent.contentproj
r6536 r6538 68 68 </Compile> 69 69 </ItemGroup> 70 <ItemGroup> 71 <Compile Include="testlevel2.tmx"> 72 <Name>testlevel2</Name> 73 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 74 <Importer>TextFileImporter</Importer> 75 <Processor>TextFileContentProcessor</Processor> 76 </Compile> 77 </ItemGroup> 70 78 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 71 79 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
2015/27/ohjaajat/TheLegendOfGabriel/TheLegendOfGabriel/TheLegendOfGabrielContent/testlevel.tmx
r6536 r6538 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 <map version="1.0" orientation="orthogonal" renderorder="right-down" width="20" height="15" tilewidth="20" tileheight="20" nextobjectid=" 1">2 <map version="1.0" orientation="orthogonal" renderorder="right-down" width="20" height="15" tilewidth="20" tileheight="20" nextobjectid="2"> 3 3 <tileset firstgid="1" source="LegendOfGabrielTileset.tsx"/> 4 4 <layer name="base" width="20" height="15"> 5 5 <data encoding="base64" compression="zlib"> 6 eJxjYmBgY BqmmBkJU8MMZiQxSswjRmygzCPWDmq7Dz18ccUbMxY2NrWk2otuBrnmERsOuNIVPnfgcx+x7kS3l1AeoUV6JdZubBgA7ucClg==6 eJxjYmBgYAJiZijNhIM/FDEzEqaGGcxIYpSYR4zYQJlHrB3Udh96+OKKN2YsbGxqSbUX3QxyzSM2HHClK3zuwOc+Yt2Jbi+hPEKL9Eqs3dgwAPgnApg= 7 7 </data> 8 8 </layer> 9 <objectgroup color="#65e2d8" name="exit"> 10 <object id="1" x="60" y="0" width="60" height="20"> 11 <properties> 12 <property name="goto" value="testlevel2@bottom"/> 13 </properties> 14 </object> 15 </objectgroup> 9 16 </map>
Note: See TracChangeset
for help on using the changeset viewer.