Changeset 7298
- Timestamp:
- 2016-06-14 14:57:14 (7 years ago)
- Location:
- 2016/24/AnttuK/SUO
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
2016/24/AnttuK/SUO/SUO/SUO/SUO.cs
r7270 r7298 11 11 Image plImg = LoadImage("Untitled"); 12 12 PhysicsObject player; 13 IntMeter counter; 14 15 13 16 public override void Begin() 14 17 { 18 CreateCounter(); 15 19 SetKeys(); 16 20 SetLevel(); 21 MediaPlayer.Play("music"); 22 MediaPlayer.Volume = 0.5; 23 MediaPlayer.IsRepeating = true; 24 } 25 void CreateCounter() 26 { 27 counter = new IntMeter(0); 28 Label counterDisp = new Label(); 29 counterDisp.X = Screen.Left + 100; 30 counterDisp.Y = Screen.Top - 100; 31 counterDisp.TextColor = Color.Black; 32 counterDisp.BindTo(counter); 33 counterDisp.Title = "Stars remaining"; 34 Add(counterDisp); 35 } 36 void Restart(PhysicsObject obj1, PhysicsObject obj2) 37 { 38 ClearAll(); 39 MessageDisplay.Add("You Lose! Try Again?"); 40 CreateCounter(); 41 SetKeys(); 42 SetLevel(); 43 } 44 void Win(PhysicsObject obj1, PhysicsObject obj2) 45 { 46 if (counter.Value == 0) 47 { 48 ClearAll(); 49 MessageDisplay.Add("You Win!"); 50 SetLevel(); 51 Vector exampleMovement = new Vector(1, 0); 52 Mouse.IsCursorVisible = true; 53 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 54 } 17 55 } 18 56 void SetKeys() 19 57 { 20 58 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 21 Keyboard.Listen(Key.Left, ButtonState.Down, MovePlayer, null, new Vector(-20, 0)); 22 Keyboard.Listen(Key.Right, ButtonState.Down, MovePlayer, null, new Vector(20, 0)); 23 Keyboard.Listen(Key.Up, ButtonState.Down, MovePlayer, null, new Vector(0, 20)); 24 Keyboard.Listen(Key.Down, ButtonState.Down, MovePlayer, null, new Vector(0, -20)); 59 Keyboard.Listen(Key.Left, ButtonState.Down, MovePlayer, null, new Vector(-50, 0)); 60 Keyboard.Listen(Key.Right, ButtonState.Down, MovePlayer, null, new Vector(50, 0)); 61 Keyboard.Listen(Key.Up, ButtonState.Down, MovePlayer, null, new Vector(0, 50)); 62 Keyboard.Listen(Key.Down, ButtonState.Down, MovePlayer, null, new Vector(0, -50)); 63 Keyboard.Listen(Key.R, ButtonState.Down, Restart, null, player,player); 25 64 } 26 65 void SetLevel() … … 30 69 tiles.SetTileMethod('#', CreateRect, Color.Gray); 31 70 tiles.SetTileMethod('P', CreatePlayer); 32 tiles.Execute(32,32); 71 tiles.SetTileMethod('!', CreateEnemy); 72 tiles.SetTileMethod('^', CreateFlag); 73 tiles.SetTileMethod('@', CreateSafe); 74 tiles.SetTileMethod('$', CreateStar); 75 tiles.Execute(50,50); 33 76 } 34 77 void CreateRect(Vector pos, double width, double height, Color clr) … … 38 81 tile.Shape = Shape.Rectangle; 39 82 tile.Color = clr; 83 tile.Tag = "tile"; 40 84 Add(tile); 41 85 } 42 86 void CreatePlayer(Vector pos, double width, double height) 43 87 { 44 player = new PhysicsObject(width /2,height/2);88 player = new PhysicsObject(width*0.5,height*0.5); 45 89 player.Position = pos; 46 90 player.Shape = Shape.Circle; 47 91 player.Image = plImg; 48 92 player.Restitution = 1.0; 49 player.LinearDamping = 1.0; 50 player.CanRotate = false; 93 player.LinearDamping = 0.9; 94 //player.CanRotate = false; 95 player.Tag = "player"; 96 player.CollisionIgnoreGroup = 1; 97 AddCollisionHandler(player, "flag", Win); 98 AddCollisionHandler(player, "star", CountAndDestroy); 51 99 Add(player); 100 } 101 void CreateEnemy(Vector pos, double width, double height) 102 { 103 RandomMoverBrain dumbEnem = new RandomMoverBrain(); 104 dumbEnem.Speed = 100; 105 dumbEnem.ChangeMovementSeconds = 1; 106 107 FollowerBrain smartEnem = new FollowerBrain("player"); 108 smartEnem.Speed = 100; 109 smartEnem.DistanceFar = 100; 110 smartEnem.StopWhenTargetClose = false; 111 smartEnem.FarBrain = dumbEnem; 112 113 PhysicsObject enem = new PhysicsObject(width*0.75, height*0.75); 114 enem.Position = pos; 115 enem.Shape = Shape.Diamond; 116 enem.Color = Color.Ruby; 117 enem.Restitution = 1.0; 118 enem.Tag = "enemy"; 119 enem.Brain = smartEnem; 120 121 AddCollisionHandler(enem, "player", Restart); 122 Add(enem); 52 123 } 53 124 void MovePlayer(Vector vect) … … 55 126 player.Hit(vect); 56 127 } 128 void CreateFlag(Vector pos, double width, double height) 129 { 130 PhysicsObject flag = PhysicsObject.CreateStaticObject(width, height); 131 flag.Position = pos; 132 flag.Shape = Shape.Triangle; 133 flag.Color = Color.Cyan; 134 flag.Tag = "flag"; 135 flag.CollisionIgnoreGroup = 2; 136 Add(flag); 137 } 138 void CreateSafe(Vector pos, double width, double height) 139 { 140 PhysicsObject safe = PhysicsObject.CreateStaticObject(width, height); 141 safe.Position = pos; 142 safe.Shape = Shape.Circle; 143 safe.Color = Color.Black; 144 safe.Tag = "safe"; 145 safe.CollisionIgnoreGroup = 1; 146 Add(safe); 147 } 148 void CreateStar(Vector pos, double width, double height) 149 { 150 PhysicsObject star = PhysicsObject.CreateStaticObject(width, height); 151 star.Position = pos; 152 star.Shape = Shape.Star; 153 star.Color = Color.Yellow; 154 star.Tag = "star"; 155 counter.Value ++; 156 Add(star); 157 } 158 void CountAndDestroy(PhysicsObject obj1, PhysicsObject obj2) 159 { 160 obj2.Destroy(); 161 counter.Value --; 162 } 57 163 } -
2016/24/AnttuK/SUO/SUO/SUO/SUO.csproj.Debug.cachefile
r7270 r7298 1 1 Content\level1.xnb 2 2 Content\Untitled.xnb 3 Content\music.xnb 4 Content\music.wma 3 5 Content\level1.txt 4 6 Content\Untitled.png 7 Content\music.mp3 -
2016/24/AnttuK/SUO/SUO/SUO/bin/x86/Debug/Content/level1.txt
r7270 r7298 1 ########## 2 #### P# 3 ## ## ## 4 ## #### ## 5 ####### ## 6 # ## ## 7 ### ## ## 8 #### ## 9 ####### # 10 ########## 1 2 3 ####### ####### 4 #$ ! $# # !# !# ############## 5 ### ####$##$#### ! # 6 #P$ @ @ $ !^! # 7 ### ###$##$##### ! # 8 #$ ! $# # !# !# ############## 9 ####### ####### -
2016/24/AnttuK/SUO/SUO/SUO/obj/x86/Debug/ContentPipeline-{943DB61E-18B1-4023-9157-F466AB52EC42}.xml
r7270 r7298 9 9 <Options>None</Options> 10 10 <Output>C:\MyTemp\AnttuK\SUO\SUO\SUO\bin\x86\Debug\Content\level1.xnb</Output> 11 <Time>2016-06-1 3T14:58:57.6378337+03:00</Time>11 <Time>2016-06-14T14:54:41.2542867+03:00</Time> 12 12 </Item> 13 13 <Item> … … 19 19 <Output>C:\MyTemp\AnttuK\SUO\SUO\SUO\bin\x86\Debug\Content\Untitled.xnb</Output> 20 20 <Time>2016-06-13T14:10:57.4488745+03:00</Time> 21 </Item> 22 <Item> 23 <Source>music.mp3</Source> 24 <Name>music</Name> 25 <Importer>Mp3Importer</Importer> 26 <Processor>SongProcessor</Processor> 27 <Options>None</Options> 28 <Output>C:\MyTemp\AnttuK\SUO\SUO\SUO\bin\x86\Debug\Content\music.xnb</Output> 29 <Extra>C:\MyTemp\AnttuK\SUO\SUO\SUO\bin\x86\Debug\Content\music.wma</Extra> 30 <Time>2016-06-14T14:45:05.959763+03:00</Time> 21 31 </Item> 22 32 <BuildSuccessful>true</BuildSuccessful> -
2016/24/AnttuK/SUO/SUO/SUO/obj/x86/Debug/SUO.csproj.FileListAbsolute.txt
r7270 r7298 11 11 C:\MyTemp\AnttuK\SUO\SUO\SUO\bin\x86\Debug\Content\Untitled.xnb 12 12 C:\MyTemp\AnttuK\SUO\SUO\SUO\bin\x86\Debug\Content\Untitled.png 13 C:\MyTemp\AnttuK\SUO\SUO\SUO\bin\x86\Debug\Content\music.xnb 14 C:\MyTemp\AnttuK\SUO\SUO\SUO\bin\x86\Debug\Content\music.wma 15 C:\MyTemp\AnttuK\SUO\SUO\SUO\bin\x86\Debug\Content\music.mp3 -
2016/24/AnttuK/SUO/SUO/SUO/obj/x86/Debug/cachefile-{943DB61E-18B1-4023-9157-F466AB52EC42}-targetpath.txt
r7270 r7298 1 1 Content\level1.xnb 2 2 Content\Untitled.xnb 3 Content\music.xnb 4 Content\music.wma 3 5 Content\level1.txt 4 6 Content\Untitled.png 7 Content\music.mp3 -
2016/24/AnttuK/SUO/SUO/SUOContent/SUOContent.contentproj
r7270 r7298 61 61 </Compile> 62 62 </ItemGroup> 63 <ItemGroup> 64 <Compile Include="music.mp3"> 65 <Name>music</Name> 66 <Importer>Mp3Importer</Importer> 67 <Processor>SongProcessor</Processor> 68 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 69 </Compile> 70 </ItemGroup> 63 71 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 64 72 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
2016/24/AnttuK/SUO/SUO/SUOContent/level1.txt
r7270 r7298 1 ########## 2 #### P# 3 ## ## ## 4 ## #### ## 5 ####### ## 6 # ## ## 7 ### ## ## 8 #### ## 9 ####### # 10 ########## 1 2 3 ####### ####### 4 #$ ! $# # !# !# ############## 5 ### ####$##$#### ! # 6 #P$ @ @ $ !^! # 7 ### ###$##$##### ! # 8 #$ ! $# # !# !# ############## 9 ####### #######
Note: See TracChangeset
for help on using the changeset viewer.