Changeset 1146
- Timestamp:
- 2010-07-07 14:53:25 (13 years ago)
- Location:
- 2010/27/frjolehm/The King of the island/The King of the island
- Files:
-
- 9 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/27/frjolehm/The King of the island/The King of the island/Content/Content.contentproj
r1125 r1146 35 35 </ItemGroup> 36 36 <ItemGroup> 37 <Compile Include="Kuollut1.png"> 38 <Name>Kuollut1</Name> 39 <Importer>TextureImporter</Importer> 40 <Processor>TextureProcessor</Processor> 41 </Compile> 42 <Compile Include="Kuollut2.png"> 43 <Name>Kuollut2</Name> 44 <Importer>TextureImporter</Importer> 45 <Processor>TextureProcessor</Processor> 46 </Compile> 47 </ItemGroup> 48 <ItemGroup> 49 <Compile Include="Aita.png"> 50 <Name>Aita</Name> 51 <Importer>TextureImporter</Importer> 52 <Processor>TextureProcessor</Processor> 53 </Compile> 54 </ItemGroup> 55 <ItemGroup> 37 56 <Compile Include="Tipu1.png"> 38 57 <Name>Tipu1</Name> … … 40 59 <Processor>TextureProcessor</Processor> 41 60 </Compile> 61 <Compile Include="Tipu2.png"> 62 <Name>Tipu2</Name> 63 <Importer>TextureImporter</Importer> 64 <Processor>TextureProcessor</Processor> 65 </Compile> 42 66 </ItemGroup> 43 67 </Project> -
2010/27/frjolehm/The King of the island/The King of the island/Peli.cs
r1125 r1146 1 1 using System; 2 2 using Jypeli; 3 using Jypeli.ScreenObjects; 3 4 using Jypeli.Widgets; 4 5 using Jypeli.Assets; … … 6 7 public class Peli : PhysicsGame 7 8 { 9 8 10 PlatformCharacter pelaaja1; 9 11 PlatformCharacter pelaaja2; … … 14 16 PhysicsObject yläreuna; 15 17 18 const int Joukkueenkoko = 3; 19 int Pelaajan1joukkue = Joukkueenkoko; 20 int Pelaajan2joukkue = Joukkueenkoko; 21 16 22 Boolean Pelaajan1JuoksuAskel; 17 23 Boolean Pelaajan2JuoksuAskel; 18 19 const double Juoksunopeus = 20; 24 const double Juoksunopeus = 100;//20 25 const double Juoksunkiihtyvyys = 2.5; 26 double Pelaajan1Juoksunopeus = Juoksunopeus; 27 double Pelaajan2Juoksunopeus = Juoksunopeus; 20 28 21 29 protected override void Begin() … … 27 35 { 28 36 //Kuoleman juoksu 29 if (peliMuoto == 1){ 30 LuoKenttä(800,700); 37 if (peliMuoto == 1) 38 { 39 LuoKenttä(800,700); 40 Camera.ZoomToLevel(); 41 LuoElämät(); 31 42 AddCollisionHandler(oikeareuna, JuoksuVoitto); 32 pelaaja1 = LuoUkko(Level.Left + 30,Level.Bottom + 75, 100, 100);33 pelaaja2 = LuoUkko(Level.Left+ 30,Level.Bottom + 200, 100, 100);43 pelaaja1 = LuoUkko(Level.Left + 30,Level.Bottom + 75,85, 75,"Tipu1"); 44 pelaaja2 = LuoUkko(Level.Left+ 30,Level.Bottom + 200,85, 75,"Tipu2"); 34 45 JuoksuOhjaimet(); 35 46 } 36 47 else if (peliMuoto == 2) 48 { 49 LuoKenttä(3000, 1000); 50 LuoTausta(3000, Level.Bottom); 51 pelaaja1 = LuoUkko(Level.Left + 30, Level.Bottom + 75, 85, 75, "Tipu1"); 52 Gravity = new Vector(0, -1000); 53 54 Camera.Follow(pelaaja1); 55 LuoElämät(); 56 JuoksuOhjaimet(); 57 } 58 59 } 60 61 void LuoTausta(int w, double y) 62 { 63 for (int x = 1; x < w; x += 100) 64 { 65 LuoTaustaEsineitä(x, y, 50, 50, "Aita"); 66 } 67 } 68 void LuoTaustaEsineitä(double x, double y, double w, double h, string nimi) 69 { 70 PhysicsObject ukko = new PhysicsObject(w,h,Shapes.Rectangle); 71 ukko.Image = LoadImage(nimi); 72 ukko.X = x; 73 ukko.Y = y; 74 Add(ukko); 37 75 } 38 76 … … 52 90 53 91 alareuna = Level.CreateBottomBorder(); 54 alareuna.IsVisible = false; 55 56 57 Camera.ZoomToLevel(); 92 alareuna.Color = Color.Green; 93 alareuna.IsVisible = true; 58 94 59 95 } … … 76 112 if (näppäin == Pelaajan1JuoksuAskel) 77 113 { 78 Liikuta(ukko, Juoksunopeus); 114 Pelaajan1Juoksunopeus += Juoksunkiihtyvyys; 115 Liikuta(ukko,Pelaajan1Juoksunopeus); 79 116 if (Pelaajan1JuoksuAskel == true) 80 117 { 81 118 Pelaajan1JuoksuAskel = false; 82 119 } 83 120 else 121 { 122 Pelaajan1JuoksuAskel = true; 123 } 124 125 } 126 if (Pelaajan1Juoksunopeus >= Juoksunopeus) 127 { 128 Pelaajan1Juoksunopeus -= 1; 84 129 } 85 130 } … … 88 133 if (näppäin == Pelaajan2JuoksuAskel) 89 134 { 90 Liikuta(ukko, Juoksunopeus); 135 Pelaajan2Juoksunopeus += Juoksunkiihtyvyys; 136 Liikuta(ukko, Pelaajan2Juoksunopeus); 91 137 if (Pelaajan2JuoksuAskel == true) 92 138 { 93 139 Pelaajan2JuoksuAskel = false; 94 140 } 95 } 96 } 97 } 98 99 void JuoksuVoitto(PhysicsObject maali, PlatformCharacter kohde) 141 else 142 { 143 Pelaajan2JuoksuAskel = true; 144 } 145 } 146 if (Pelaajan2Juoksunopeus >= Juoksunopeus) 147 { 148 Pelaajan2Juoksunopeus -= 1; 149 } 150 } 151 } 152 153 void JuoksuVoitto(PhysicsObject maali, PhysicsObject kohde) 100 154 { 101 155 if(kohde == pelaaja1) 102 156 { 103 157 ClearAll(); 158 Pelaajan2joukkue--; 159 Aloitapikkupeli(2); 104 160 } 105 161 else if (kohde == pelaaja2) 106 162 { 107 163 ClearAll(); 108 } 109 } 110 111 164 Pelaajan2joukkue--; 165 Aloitapikkupeli(2); 166 } 167 } 168 169 void LuoElämät() 170 { 171 for(int i = 1; i < Joukkueenkoko+1; i++) 172 { 173 if (i <= Pelaajan1joukkue) 174 { 175 LuoUkkokuva(Screen.Left + i * 50, Screen.Top - 25, 40, 35, "Tipu1"); 176 } 177 else 178 { 179 LuoUkkokuva(Screen.Left + i * 50, Screen.Top - 25, 40, 35, "Kuollut1"); 180 } 181 if (i <= Pelaajan2joukkue) 182 { 183 LuoUkkokuva(Screen.Right - i * 50, Screen.Top - 25, 40, 35, "Tipu2"); 184 } 185 else 186 { 187 LuoUkkokuva(Screen.Right - i * 50, Screen.Top - 25, 40, 35, "Kuollut2"); 188 } 189 } 190 } 191 192 void LuoUkkokuva(double x, double y, double w, double h, string nimi) 193 { 194 ImageDisplay ukko = new ImageDisplay(); 195 ukko.Image = LoadImage(nimi); 196 ukko.AutoSize = false; 197 ukko.Width = w; 198 ukko.Height = h; 199 ukko.X = x; 200 ukko.Y = y; 201 Add(ukko); 202 203 } 112 204 113 205 void Liikuta(PlatformCharacter ukko, double nopeus) … … 116 208 } 117 209 118 PlatformCharacter LuoUkko(double x, double y, double kokoX, double kokoY )210 PlatformCharacter LuoUkko(double x, double y, double kokoX, double kokoY, string nimi) 119 211 { 120 212 PlatformCharacter ukko = new PlatformCharacter(kokoX, kokoY, Shapes.Circle); … … 122 214 ukko.X = x; 123 215 ukko.Y = y; 124 ukko.Image = LoadImage( "Tipu1");216 ukko.Image = LoadImage(nimi); 125 217 Add(ukko); 126 218 return ukko;
Note: See TracChangeset
for help on using the changeset viewer.