Changeset 9355
- Timestamp:
- 2017-08-02 14:56:26 (6 years ago)
- Location:
- 2017/31/BeaJ
- Files:
-
- 1 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
2017/31/BeaJ/Tasohyppelypeli2/Tasohyppelypeli2/Tasohyppelypeli2/Tasohyppelypeli2.cs
r9335 r9355 13 13 const int RUUDUN_KOKO = 40; 14 14 15 P latformCharacterpelaaja1;15 Pelaaja pelaaja1; 16 16 Image pelaajanKuva = LoadImage("sydanemoj2i"); 17 17 Image hirvionKuva = LoadImage("hirviö"); … … 23 23 { 24 24 Gravity = new Vector(0, -1000); 25 25 26 26 27 LuoKentta(); … … 35 36 { 36 37 TileMap kentta = TileMap.FromLevelAsset("kentta1"); 38 kentta.SetTileMethod('N', LisaaPelaaja); 37 39 kentta.SetTileMethod('#', LisaaTaso); 38 40 kentta.SetTileMethod('*', LisaaTahti); 39 41 kentta.SetTileMethod('+', LisaaAvain); 40 kentta.SetTileMethod('N', LisaaPelaaja);42 41 43 kentta.SetTileMethod('K', LisaaHirvio); 44 kentta.SetTileMethod('L', LisaaSeuraajaHirvio); 42 45 kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 43 46 44 47 Level.CreateBorders(); 45 Level.Background.CreateGradient(Color. Aquamarine, Color.Purple);48 Level.Background.CreateGradient(Color.Purple, Color.Aqua); 46 49 } 47 50 … … 50 53 PhysicsObject taso = PhysicsObject.CreateStaticObject(leveys, korkeus); 51 54 taso.Position = paikka; 52 taso.Image = Image.FromGradient (RUUDUN_KOKO, RUUDUN_KOKO, Color. LimeGreen, Color.Green);55 taso.Image = Image.FromGradient (RUUDUN_KOKO, RUUDUN_KOKO, Color.Aqua, Color.Aqua); 53 56 Add(taso); 54 57 } … … 66 69 void LisaaPelaaja(Vector paikka, double leveys, double korkeus) 67 70 { 68 pelaaja1 = new P latformCharacter(leveys, korkeus);71 pelaaja1 = new Pelaaja(leveys, korkeus); 69 72 pelaaja1.Position = paikka; 70 73 pelaaja1.Mass = 4.0; 74 pelaaja1.Tag = "pelaaja"; 71 75 pelaaja1.Image = pelaajanKuva; 72 76 AddCollisionHandler(pelaaja1, "tahti", TormaaTahteen); 73 Add(pelaaja1); 77 AddCollisionHandler(pelaaja1, "hirvio", TormaaHirvioon); 78 Add(pelaaja1); 74 79 80 Label pisteNaytto = new Label(); 81 pisteNaytto.X = Screen.Left + 100; 82 pisteNaytto.Y = Screen.Top - 100; 83 pisteNaytto.TextColor = Color.Black; 84 pisteNaytto.Color = Color.White; 85 86 pisteNaytto.BindTo(pelaaja1.ElamaLaskuri); 87 Add(pisteNaytto); 75 88 76 89 } … … 110 123 tahti.Destroy(); 111 124 } 112 125 void TormaaHirvioon(PhysicsObject hahmo, PhysicsObject tahti) 126 { 127 pelaaja1.ElamaLaskuri.AddValue(-1); 128 } 113 129 void LisaaAvain(Vector paikka, double leveys, double korkeus) 114 130 { … … 127 143 { 128 144 PhysicsObject hirvio; 129 hirvio = new PlatformCharacter(leveys, korkeus );145 hirvio = new PlatformCharacter(leveys, korkeus * 0.95); 130 146 hirvio.Position = paikka; 131 147 hirvio.Mass = 4.0; 132 148 hirvio.Image = hirvionKuva; 133 FollowerBrain seuraajanAivot = new FollowerBrain(pelaaja1); 149 hirvio.Tag = "hirvio"; 150 151 PlatformWandererBrain tasoAivot = new PlatformWandererBrain(); 152 tasoAivot.Speed = 100; 153 tasoAivot.FallsOffPlatforms = true; 154 tasoAivot.JumpSpeed = 700; 155 tasoAivot.TriesToJump = true; 156 hirvio.Brain = tasoAivot; 157 158 AddCollisionHandler(hirvio, "tahti", TormaaTahteen); 159 Add(hirvio); 160 } 161 162 void LisaaSeuraajaHirvio(Vector paikka, double leveys, double korkeus) 163 { 164 PhysicsObject hirvio; 165 hirvio = new PlatformCharacter(leveys, korkeus * 0.95); 166 hirvio.Position = paikka; 167 hirvio.Mass = 4.0; 168 hirvio.Image = hirvionKuva; 169 hirvio.Tag = "hirvio"; 170 171 FollowerBrain seuraajanAivot = new FollowerBrain("pelaaja"); 134 172 seuraajanAivot.Speed = 300; // Millä nopeudella kohdetta seurataan 135 173 seuraajanAivot.DistanceFar = 600; // Etäisyys jolla aletaan seurata kohdetta 136 174 seuraajanAivot.DistanceClose = 200; // Etäisyys jolloin ollaan lähellä kohdetta 137 seuraajanAivot.StopWhenTargetClose = false; // Pysähdytään kun ollaan lähellä kohdetta 138 //seuraajanAivot.FarBrain = satunnaisAivot; // Käytetään satunnaisaivoja kun ollaan kaukana 175 seuraajanAivot.StopWhenTargetClose = true; // Pysähdytään kun ollaan lähellä kohdetta 176 // seuraajanAivot.FarBrain = satunnaisAivot; // Käytetään satunnaisaivoja kun ollaan kaukana 177 178 139 179 hirvio.Brain = seuraajanAivot; 140 180 … … 142 182 Add(hirvio); 143 183 } 184 } 144 185 186 class Pelaaja : PlatformCharacter 187 { 188 private IntMeter elamaLaskuri = new IntMeter(3, 0, 3); 189 public IntMeter ElamaLaskuri { get { return elamaLaskuri; } } 145 190 191 public Pelaaja(double leveys, double korkeus) 192 : base(leveys, korkeus) 193 { 194 elamaLaskuri.LowerLimit += delegate { this.Destroy(); }; 195 } 146 196 } -
2017/31/BeaJ/Tasohyppelypeli2/Tasohyppelypeli2/Tasohyppelypeli2/obj/x86/Debug/ContentPipeline-{FB1067CC-FEED-45F1-8CB8-8F3DD59AB260}.xml
r9335 r9355 36 36 <Options>None</Options> 37 37 <Output>C:\MyTemp\BeaJ\Tasohyppelypeli2\Tasohyppelypeli2\Tasohyppelypeli2\bin\x86\Debug\Content\kentta1.xnb</Output> 38 <Time>2017-08-02T1 1:46:46.8576602+03:00</Time>38 <Time>2017-08-02T14:49:21.0490374+03:00</Time> 39 39 </Item> 40 40 <Item> -
2017/31/BeaJ/Tasohyppelypeli2/Tasohyppelypeli2/Tasohyppelypeli2Content/kentta1.txt
r9335 r9355 1 ################################################################################################################################################################################# 2 #.................#................#.............................. ..*+*.........................................................................................................#3 #*****************#................#..............................#######.................... ...................................................................................#4 #........................ K.........#............**.......##.............#.......................................................................................................#5 #...........N..........#############..................#####.............#............................................. ..........................................................#6 #........########......................###########...............########........................................... ............................................................#7 #........#......#....**...........######..................... ...................................................................................................................#8 ##########......##..##############.......#................. ####.................................................................................................................#9 #...................................................###################.............. ...........................................................................................#10 #...... ............................................#............................................................................................................................#11 #.......................... .......................#.............................###################.............................................................................#12 #............##.............. ...................#...............................................................................................................................#13 #...........#..#...............................#.................. ..............................................................................................................#14 #........ ..#....#.............................#.................................................................................................................................#15 #....... ..#......#...........................#..................................................................................................................................#16 ################################################################################################################################################################################# 1 ################################################################################################################################################################################## 2 #.................#................#..............................K.*+*..........................................................................................................# 3 #*****************#................#..............................#######....................*...K................................................................................# 4 #........................L.........#............**.......##.............#......*........##################........................................................................# 5 #...........N..........#############..................#####.............#.............................................L..........................................................# 6 #........########......................###########...............########...........................................#####........................................................# 7 #........#......#....**...........######.....................K...............*....................................................................................................# 8 ##########......##..##############.......#.................K####........*......................###................................................................................# 9 #...................................................###################..............########..............................*******...............K......................................# 10 #......*....*............*.................###.........#..............*......................K.............................................#########.................................# 11 #..........................*......................#.............................###################..............................................................................# 12 #............##..............######.............K#..................K................................................L...........*************................................................# 13 #...........#..#...............................#..................########....................................##############.....................................................# 14 #........*.#....#.............................#..##.......................#......................................................................................................# 15 #.......*.#......#............L..............#.....#................................L.............K..............................................................................# 16 ##################################################################################################################################################################################
Note: See TracChangeset
for help on using the changeset viewer.