Changeset 906
- Timestamp:
- 2010-06-16 11:42:45 (13 years ago)
- Location:
- 2010/24/kaosmaja/Tasohyppely1
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/24/kaosmaja/Tasohyppely1/Peli.cs
r894 r906 7 7 class Tasohyppely : PhysicsGame 8 8 { 9 const double nopeus = 200;10 const double hyppyVoima = 4000;9 const double nopeus = 350; 10 const double hyppyVoima = 7000; 11 11 12 12 IntMeter pisteLaskuri; … … 17 17 int kenttaNro; // monesko kenttä on menossa 18 18 19 const int ruudunLeveys = 50; 20 const int ruudunKorkeus = 50; 19 21 20 22 protected override void Begin() … … 23 25 Level.Width = 2000; 24 26 Level.Height = 1000; 25 27 pisteLaskuri = new IntMeter(0); 26 28 27 29 … … 45 47 46 48 // Asetetaan painovoima 47 Gravity = new Vector(0, -1000); 48 49 luoKentta(); 49 Gravity = new Vector(0, -1500); 50 if (kenttaNro == 1) 51 { 52 luoKentta(); 53 } 54 if (kenttaNro == 2) 55 { 56 LuoKentta2(); 57 } 50 58 lisaaNappaimet(); 51 59 Camera.Follow(pelaaja1); … … 55 63 { 56 64 // Luodaan pistelaskuri 57 pisteLaskuri = new IntMeter(0); 65 58 66 59 67 // luodaan pistelaskunäyttö … … 83 91 lisaaTaso(-300, 0); 84 92 lisaaTaso(-500, -200); 93 lisaaTaso(-700, 0); 94 lisaaTaso(-250, -100); 85 95 LisaaTaso2(-10, -150); 86 96 LisaaTaso2(-10, -50); 87 97 LisaaTaso2(35, 55); 88 98 89 LisaaSmiley(-200, -300); 90 LisaaSmiley( 20, 80 ); 91 99 int i = 15; 100 while (i < 50) 101 { 102 int sade = RandomGen.NextInt(5, 20); 103 PhysicsObject smiley = LisaaSmiley( 104 RandomGen.NextDouble( 105 Level.Left, 106 Level.Right 107 ), 108 RandomGen.NextDouble( 109 Level.Top, 110 Level.Bottom 111 )); 112 smiley.Color = Color.LightYellow; 113 Add(smiley); 114 i++; 115 } 92 116 lisaaMaali(); 93 117 lisaaPelaajat(); 118 } 119 void LuoKentta2() 120 { 121 TileMap ruudut = TileMap.FromFile("kentta.txt"); 122 ruudut['='] = LuoPalikka; 123 ruudut['*'] = LuoSmiley2; 124 ruudut['S'] = LuoS; 125 ruudut['!'] = lisaaMaali; 126 ruudut['@'] = lisaaPelaajat; 127 ruudut.Insert(ruudunLeveys, ruudunKorkeus); 128 Camera.ZoomToLevel(); 129 } 130 PhysicsObject LuoPalikka() 131 { 132 PhysicsObject Palikka = PhysicsObject.CreateStaticObject(50.0, 50.0); 133 return Palikka; 134 } 135 PhysicsObject LuoSmiley2() 136 { 137 PhysicsObject smiley2 = PhysicsObject.CreateStaticObject(10.0, 10.0); 138 smiley2.Image = LoadImage(smiley2); 139 smiley2.Tag = smiley2; 140 return smiley2; 141 } 142 PhysicsObject LuoS() 143 { 144 PhysicsObject S = new PhysicsObject(15.0, 15.0); 145 return S; 94 146 } 95 147 … … 110 162 Add(taso2); 111 163 } 112 voidLisaaSmiley( double x, double y )164 PhysicsObject LisaaSmiley( double x, double y ) 113 165 { 114 166 PhysicsObject smiley = new PlatformCharacter( 10, 10 ); 115 smiley.X = x;116 smiley.Y = y;117 167 smiley.Image = LoadImage("smiley"); 118 168 smiley.Tag = "smiley"; 169 smiley.Position = new Vector(x, y); 170 119 171 Add(smiley); 120 } 121 void lisaaPelaajat() 172 return smiley; 173 } 174 175 PlatformCharacter lisaaPelaajat() 122 176 { 123 177 pelaaja1 = new PlatformCharacter(40, 40); … … 130 184 131 185 Add(pelaaja1); 132 } 133 134 void lisaaMaali() 186 return pelaaja1; 187 } 188 189 PhysicsObject lisaaMaali() 135 190 { 136 191 PhysicsObject maali = PhysicsObject.CreateStaticObject(50, 50, Shapes.Circle); … … 141 196 maali.Image = LoadImage("tahti"); 142 197 Add(maali); 198 return maali; 143 199 } 144 200 … … 190 246 pisteLaskuri.Value++; 191 247 } 248 if (otherObject.Tag.ToString() == "smiley2") 249 { 250 otherObject.Destroy(); 251 MessageDisplay.Add("Otit smileyn mukaan, sait pisteitä"); 252 pisteLaskuri.Value++; 253 } 192 254 } 193 255 -
2010/24/kaosmaja/Tasohyppely1/Tasohyppely1.csproj
r872 r906 89 89 <Content Include="Game.ico" /> 90 90 <Content Include="GameThumbnail.png" /> 91 <Content Include="kentta.txt"> 92 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 93 </Content> 91 94 </ItemGroup> 92 95 <ItemGroup>
Note: See TracChangeset
for help on using the changeset viewer.