- Timestamp:
- 2012-07-25 15:00:23 (11 years ago)
- Location:
- 2012/30/JyriP
- Files:
-
- 39 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/30/JyriP/Lofen/Lofen/Lofen/Lofen.cs
r3730 r3747 11 11 PhysicsObject player; 12 12 PhysicsObject Reaper; 13 14 int WorldCounter = 1; 15 16 13 17 public override void Begin() 14 18 { 19 IsMouseVisible = true; 15 20 Window.Title = "Lofen"; 16 21 Start(); … … 20 25 void Start() 21 26 { 22 CreateBackgroundWorld(); 23 CreateWorld(); 24 SetControls(); 25 26 } 27 MainMenu(); 28 } 29 30 //Menu 31 void MainMenu() 32 { 33 34 ClearAll(); 35 MultiSelectWindow mainMenu = new MultiSelectWindow("Lofen", "Start New Game", "Exit"); 36 mainMenu.DefaultCancel = 3; 37 mainMenu.DefaultCancel = -1; 38 mainMenu.Color = Level.BackgroundColor; 39 mainMenu.ItemSelected += pressedMenuItem; 40 41 Add(mainMenu); 42 } 43 44 void pressedMenuItem(int MenuItem) 45 { 46 switch (MenuItem) 47 { 48 case 0: 49 CreateBackgroundWorld(); 50 CreateWorld1(); 51 SetControls(); 52 53 break; 54 55 case 1: 56 Exit(); 57 break; 58 } 59 } 60 27 61 28 62 void CreateBackgroundWorld() 29 63 { 30 64 TileMap world = TileMap.FromLevelAsset("World/bgMap"); 31 world.SetTileMethod('.', bg); 65 world.SetTileMethod('.', bgGrass); 66 world.SetTileMethod('s', bgSand); 67 world.SetTileMethod('w', bgBWater); 68 world.SetTileMethod('q', bgWater); 32 69 world.Execute(32, 32); 33 70 } 34 71 35 void bg (Vector pos, double width, double height)72 void bgGrass(Vector pos, double width, double height) 36 73 { 37 74 PhysicsObject tileBG = PhysicsObject.CreateStaticObject(width, height); 38 75 tileBG.IgnoresCollisionResponse = true; 39 76 40 Image texture Grass = Game.LoadImage("World/grass");41 tileBG.Image = texture Grass;77 Image texture = Game.LoadImage("World/textures/grass"); 78 tileBG.Image = texture; 42 79 43 80 tileBG.Position = pos; … … 49 86 } 50 87 51 void CreateWorld() 52 { 53 TileMap world = TileMap.FromLevelAsset("map"); 88 void bgSand(Vector pos, double width, double height) 89 { 90 PhysicsObject tileBG = PhysicsObject.CreateStaticObject(width, height); 91 tileBG.IgnoresCollisionResponse = true; 92 93 Image texture = Game.LoadImage("World/textures/sand"); 94 tileBG.Image = texture; 95 96 tileBG.Position = pos; 97 tileBG.Shape = Shape.Rectangle; 98 99 100 101 Add(tileBG, -1); 102 } 103 104 void bgBWater(Vector pos, double width, double height) 105 { 106 PhysicsObject tileBG = PhysicsObject.CreateStaticObject(width, height); 107 tileBG.IgnoresCollisionResponse = false; 108 109 Image[] texture = Game.LoadImages("World/textures/bWater", "World/textures/bWater2"); 110 tileBG.Animation = new Animation(texture); 111 112 tileBG.Animation.FPS = 3; 113 tileBG.Animation.Start(); 114 115 tileBG.Position = pos; 116 tileBG.Shape = Shape.Rectangle; 117 118 119 120 Add(tileBG, -1); 121 } 122 123 void bgWater(Vector pos, double width, double height) 124 { 125 PhysicsObject tileBG = PhysicsObject.CreateStaticObject(width, height); 126 tileBG.IgnoresCollisionResponse = false; 127 128 Image[] texture = Game.LoadImages("World/textures/Water", "World/textures/Water2"); 129 tileBG.Animation = new Animation(texture); 130 131 tileBG.Animation.FPS = 3; 132 tileBG.Animation.Start(); 133 134 tileBG.Position = pos; 135 tileBG.Shape = Shape.Rectangle; 136 137 138 139 Add(tileBG, -1); 140 } 141 142 void CreateWorld1() 143 { 144 TileMap world = TileMap.FromLevelAsset("World/map"); 54 145 55 146 //Ympäristö … … 67 158 world.Execute(32, 32); 68 159 69 player = CreatePlayer(Level.Left + 20, 0); 70 71 Reaper = CreateReaper(Level.Bottom - 20, 0); 72 } 73 160 player = CreatePlayer(Level.Left + 200, 0); 161 162 Reaper = CreateReaper(Level.Left + 200.0, 200); 163 } 74 164 //Player, NPC 75 165 PhysicsObject CreatePlayer(double x, double y) … … 83 173 Player.Animation.Start(); 84 174 Player.CanRotate = false; 175 Player.Tag = "Player"; 85 176 86 177 Add(Player, 1); … … 99 190 Reaper.CanRotate = false; 100 191 192 RandomMoverBrain reaperAI = new RandomMoverBrain(50); 193 reaperAI.ChangeMovementSeconds = 5; 194 195 Reaper.Brain = reaperAI; 196 101 197 Add(Reaper, 1); 102 198 return Reaper; … … 110 206 tile.IgnoresCollisionResponse = true; 111 207 112 Image texture Grass = Game.LoadImage("World/grass");113 tile.Image = texture Grass;208 Image texture = Game.LoadImage("World/textures/grass"); 209 tile.Image = texture; 114 210 115 211 tile.Position = pos; … … 126 222 tile.CollisionIgnoreGroup = 1; 127 223 128 Image texture Grass = Game.LoadImage("World/rock");129 tile.Image = texture Grass;224 Image texture = Game.LoadImage("World/textures/rock"); 225 tile.Image = texture; 130 226 131 227 tile.Position = pos; … … 141 237 tile.CollisionIgnoreGroup = 1; 142 238 143 Image textureGrass = Game.LoadImage("World/tree"); 144 tile.Image = textureGrass; 145 239 Image[] texture = Game.LoadImages("World/textures/tree", "World/textures/tree2"); 240 tile.Animation = new Animation(texture); 241 tile.Animation.FPS = 1; 242 tile.Animation.Start(); 146 243 tile.Position = pos; 147 244 tile.Shape = Shape.Rectangle; … … 158 255 tile.CollisionIgnoreGroup = 1; 159 256 160 Image texture Grass = Game.LoadImage("World/houseRoofL");161 tile.Image = texture Grass;257 Image texture = Game.LoadImage("World/textures/houseRoofL"); 258 tile.Image = texture; 162 259 163 260 tile.Position = pos; … … 174 271 tile.CollisionIgnoreGroup = 1; 175 272 176 Image texture Grass = Game.LoadImage("World/houseRoofR");177 tile.Image = texture Grass;273 Image texture = Game.LoadImage("World/textures/houseRoofR"); 274 tile.Image = texture; 178 275 179 276 tile.Position = pos; … … 190 287 tile.CollisionIgnoreGroup = 1; 191 288 192 Image texture Grass = Game.LoadImage("World/houseBottomL");193 tile.Image = texture Grass;289 Image texture = Game.LoadImage("World/textures/houseBottomL"); 290 tile.Image = texture; 194 291 195 292 tile.Position = pos; … … 206 303 tile.CollisionIgnoreGroup = 1; 207 304 208 Image texture Grass = Game.LoadImage("World/houseBottomR");209 tile.Image = texture Grass;305 Image texture = Game.LoadImage("World/textures/houseBottomR"); 306 tile.Image = texture; 210 307 211 308 tile.Position = pos; … … 222 319 void SetControls() 223 320 { 224 IsMouseVisible = true;225 321 Mouse.Listen(MouseButton.Left, ButtonState.Pressed, Move, ""); 322 Keyboard.Listen(Key.Escape, ButtonState.Pressed, MainMenu, ""); 226 323 } 227 324 … … 231 328 } 232 329 330 233 331 } -
2012/30/JyriP/Lofen/Lofen/LofenContent/LofenContent.contentproj
r3730 r3747 69 69 </ItemGroup> 70 70 <ItemGroup> 71 <Compile Include="World 1.txt">71 <Compile Include="World\World1.txt"> 72 72 <Name>map</Name> 73 73 <Importer>TextFileImporter</Importer> … … 77 77 </ItemGroup> 78 78 <ItemGroup> 79 <Compile Include="World\ grass.png">79 <Compile Include="World\textures\grass.png"> 80 80 <Name>grass</Name> 81 81 <Importer>TextureImporter</Importer> … … 84 84 </ItemGroup> 85 85 <ItemGroup> 86 <Compile Include="World\ rock.png">86 <Compile Include="World\textures\rock.png"> 87 87 <Name>rock</Name> 88 88 <Importer>TextureImporter</Importer> … … 99 99 </ItemGroup> 100 100 <ItemGroup> 101 <Compile Include="World\ houseRoofL.png">101 <Compile Include="World\textures\houseRoofL.png"> 102 102 <Name>houseRoofL</Name> 103 103 <Importer>TextureImporter</Importer> 104 104 <Processor>TextureProcessor</Processor> 105 105 </Compile> 106 <Compile Include="World\ houseRoofR.png">106 <Compile Include="World\textures\houseRoofR.png"> 107 107 <Name>houseRoofR</Name> 108 108 <Importer>TextureImporter</Importer> … … 111 111 </ItemGroup> 112 112 <ItemGroup> 113 <Compile Include="World\ houseBottomL.png">113 <Compile Include="World\textures\houseBottomL.png"> 114 114 <Name>houseBottomL</Name> 115 115 <Importer>TextureImporter</Importer> 116 116 <Processor>TextureProcessor</Processor> 117 117 </Compile> 118 <Compile Include="World\ houseBottomR.png">118 <Compile Include="World\textures\houseBottomR.png"> 119 119 <Name>houseBottomR</Name> 120 120 <Importer>TextureImporter</Importer> … … 123 123 </ItemGroup> 124 124 <ItemGroup> 125 <Compile Include="World\t ree.png">125 <Compile Include="World\textures\tree.png"> 126 126 <Name>tree</Name> 127 127 <Importer>TextureImporter</Importer> … … 130 130 </ItemGroup> 131 131 <ItemGroup> 132 <Compile Include="re eper.png">133 <Name>re eper</Name>134 <Importer>TextureImporter</Importer> 135 <Processor>TextureProcessor</Processor> 136 </Compile> 137 </ItemGroup> 138 <ItemGroup> 139 <Compile Include="re eper2.png">140 <Name>re eper2</Name>132 <Compile Include="reaper.png"> 133 <Name>reaper</Name> 134 <Importer>TextureImporter</Importer> 135 <Processor>TextureProcessor</Processor> 136 </Compile> 137 </ItemGroup> 138 <ItemGroup> 139 <Compile Include="reaper2.png"> 140 <Name>reaper2</Name> 141 141 <Importer>TextureImporter</Importer> 142 142 <Processor>TextureProcessor</Processor> … … 145 145 <ItemGroup> 146 146 <Folder Include="sprites\enemies\reeper\" /> 147 </ItemGroup> 148 <ItemGroup> 149 <Compile Include="World\textures\sand.png"> 150 <Name>sand</Name> 151 <Importer>TextureImporter</Importer> 152 <Processor>TextureProcessor</Processor> 153 </Compile> 154 </ItemGroup> 155 <ItemGroup> 156 <Compile Include="World\textures\bWater.png"> 157 <Name>bWater</Name> 158 <Importer>TextureImporter</Importer> 159 <Processor>TextureProcessor</Processor> 160 </Compile> 161 <Compile Include="World\textures\water.png"> 162 <Name>water</Name> 163 <Importer>TextureImporter</Importer> 164 <Processor>TextureProcessor</Processor> 165 </Compile> 166 </ItemGroup> 167 <ItemGroup> 168 <Compile Include="World\textures\bWater2.png"> 169 <Name>bWater2</Name> 170 <Importer>TextureImporter</Importer> 171 <Processor>TextureProcessor</Processor> 172 </Compile> 173 </ItemGroup> 174 <ItemGroup> 175 <Compile Include="World\textures\water2.png"> 176 <Name>water2</Name> 177 <Importer>TextureImporter</Importer> 178 <Processor>TextureProcessor</Processor> 179 </Compile> 180 </ItemGroup> 181 <ItemGroup> 182 <Compile Include="World\textures\tree2.png"> 183 <Name>tree2</Name> 184 <Importer>TextureImporter</Importer> 185 <Processor>TextureProcessor</Processor> 186 </Compile> 187 </ItemGroup> 188 <ItemGroup> 189 <Compile Include="World\map2.txt"> 190 <Name>map2</Name> 191 <Importer>TextFileImporter</Importer> 192 <Processor>TextFileContentProcessor</Processor> 193 </Compile> 194 <Compile Include="World\map3.txt"> 195 <Name>map3</Name> 196 <Importer>TextFileImporter</Importer> 197 <Processor>TextFileContentProcessor</Processor> 198 </Compile> 147 199 </ItemGroup> 148 200 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> -
2012/30/JyriP/Lofen/Lofen/LofenContent/World/bgMap.txt
r3730 r3747 16 16 ................................................................... 17 17 ................................................................... 18 .................................................................. 18 19 ................................................................... 19 20 ................................................................... … … 24 25 ................................................................... 25 26 ................................................................... 26 ................................................................... 27 ................................................................... 28 ................................................................... 29 ................................................................... 30 ................................................................... 31 ................................................................... 32 ................................................................... 33 ................................................................... 34 ................................................................... 35 ................................................................... 27 ............s......................s.............................. 28 ...ss.....ssss.............s......sssssss.....................sss.. 29 .s.ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 30 sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 31 wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww 32 qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq 33 qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
Note: See TracChangeset
for help on using the changeset viewer.