Changeset 4126
- Timestamp:
- 2013-06-13 15:06:35 (10 years ago)
- Location:
- 2013/24/AtteK/hypelypeli/hypelypeli
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
2013/24/AtteK/hypelypeli/hypelypeli/hypelypeli/hypelypeli.cs
r4107 r4126 10 10 { 11 11 int kenttaNro = 1; 12 const double nopeus = 216;12 const double nopeus = 366; 13 13 const double hyppyNopeus = 860; 14 14 const int RUUDUN_KOKO = 40; … … 20 20 Image hiilikuvaKuva = LoadImage("hiili"); 21 21 Image kivikuvakuva = LoadImage("kivi"); 22 Image rautakuvakuva = LoadImage("rauta"); 23 24 Image kultakuvakuva = LoadImage("kulta"); 25 26 22 Image rautakuvakuva = LoadImage("rauta"); 23 24 Image kultakuvakuva = LoadImage("kulta"); 27 25 SoundEffect maaliAani = LoadSoundEffect("maali"); 26 // IntMeter timanttiLaskuri; 28 27 29 28 public override void Begin() 30 29 { 31 30 ClearAll(); 32 LuoKentta("kentta" +kenttaNro);31 LuoKentta("kentta" + kenttaNro); 33 32 34 33 } … … 38 37 MediaPlayer.Play("imbossible2"); 39 38 Gravity = new Vector(0, -1000); 40 39 IntMeter timanttiLaskuri = new IntMeter(0, 0, int.MaxValue); 40 timanttiLaskuri.LowerLimit += delegate 41 { 42 kenttaNro++; 43 SeuraavaKentta(); 44 }; 41 45 TileMap kentta = TileMap.FromLevelAsset(kenttaTiedosto); 42 46 kentta.SetTileMethod('#', Lisaakivi); 43 kentta.SetTileMethod('*', LisaaT ahti);44 kentta.SetTileMethod('N', LisaaPelaaja );47 kentta.SetTileMethod('*', LisaaTimantti, timanttiLaskuri); 48 kentta.SetTileMethod('N', LisaaPelaaja, timanttiLaskuri); 45 49 kentta.SetTileMethod('S', LisaaSeuraaja); 46 50 kentta.SetTileMethod('%', Lisaamaali); 47 51 kentta.Optimize('#'); 48 kentta.SetTileMethod('h', Lisaahiili);49 kentta.SetTileMethod('r', Lisaarauta);50 kentta.SetTileMethod('k', Lisaakulta);52 kentta.SetTileMethod('h', Lisaahiili); 53 kentta.SetTileMethod('r', Lisaarauta); 54 // kentta.SetTileMethod('k', Lisaakulta); 51 55 kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 52 56 Level.CreateBorders(); … … 71 75 AddCollisionHandler(seuraaja, "pelaaja", SeuraajaSaaKiinni); 72 76 FollowerBrain aivot = new FollowerBrain("pelaaja"); 73 aivot.Speed = 2 00;77 aivot.Speed = 250; 74 78 seuraaja.Brain = aivot; 75 79 Add(seuraaja); … … 85 89 86 90 87 void LisaaTahti(Vector paikka, double leveys, double korkeus) 88 { 89 PhysicsObject tahti = PhysicsObject.CreateStaticObject(leveys, korkeus); 90 tahti.IgnoresCollisionResponse = true; 91 tahti.Position = paikka; 92 tahti.Image = tahtiKuva; 93 tahti.Tag = "tahti"; 94 Add(tahti); 91 void LisaaTimantti(Vector paikka, double leveys, double korkeus, IntMeter timanttiLaskuri) 92 { 93 PhysicsObject timantti = PhysicsObject.CreateStaticObject(leveys, korkeus); 94 timantti.IgnoresCollisionResponse = true; 95 timantti.Position = paikka; 96 timantti.Image = tahtiKuva; 97 timantti.Tag = "timantti"; 98 timanttiLaskuri.Value++; 99 Add(timantti); 95 100 } 96 101 … … 115 120 Add(kivi); 116 121 } 117 118 void Lisaarauta(Vector paikka, double leveys, double korkeus)122 123 void Lisaarauta(Vector paikka, double leveys, double korkeus) 119 124 { 120 125 PhysicsObject rauta = PhysicsObject.CreateStaticObject(leveys, korkeus); … … 125 130 Add(rauta); 126 131 127 128 } 129 130 void LisaaPelaaja(Vector paikka, double leveys, double korkeus) 131 { 132 pelaaja1 = new PlatformCharacter(1.2 * leveys, 1.2 * korkeus); 133 pelaaja1.Position = paikka; 134 pelaaja1.Mass = 4.0; 135 pelaaja1.Tag = "pelaaja"; 136 pelaaja1.Image = pelaajanKuva; 137 AddCollisionHandler(pelaaja1, "tahti", TormaaTahteen); 138 AddCollisionHandler(pelaaja1, "maali", TormasiMaaliin); 139 { 140 141 void Lisaarauta(Vector paikka, double leveys, double korkeus) 142 132 133 } 134 135 void LisaaPelaaja(Vector paikka, double leveys, double korkeus, IntMeter timanttiLaskuri) 136 { 137 pelaaja1 = new PlatformCharacter(1.2 * leveys, 1.2 * korkeus); 138 pelaaja1.Position = paikka; 139 pelaaja1.Mass = 4.0; 140 pelaaja1.Tag = "pelaaja"; 141 pelaaja1.Image = pelaajanKuva; 142 AddCollisionHandler(pelaaja1, "timantti", TormaaTimantiin); 143 AddCollisionHandler(pelaaja1, "timantti", CollisionHandler.AddMeterValue(timanttiLaskuri, -1)); 144 // AddCollisionHandler(pelaaja1, "maali", TormasiMaaliin); 145 Add(pelaaja1); 146 147 } 148 149 void lisaakulta(Vector paikka, double leveys, double korkeus) 143 150 { 144 151 PhysicsObject kulta = PhysicsObject.CreateStaticObject(leveys, korkeus); … … 149 156 Add(kulta); 150 157 151 152 Add(pelaaja1);153 158 } 154 159 void Lisaamaali(Vector paikka, double leveys, double korkeus) … … 166 171 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 167 172 168 double hyppyNopeusKentassa = Math.Min(1, kenttaNro/2)* hyppyNopeus;173 double hyppyNopeusKentassa = Math.Min(1, kenttaNro / 2) * hyppyNopeus; 169 174 170 175 Keyboard.Listen(Key.Left, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, -nopeus); … … 191 196 } 192 197 193 void TormaaT ahteen(PhysicsObject hahmo, PhysicsObject tahti)198 void TormaaTimantiin(PhysicsObject hahmo, PhysicsObject tahti) 194 199 { 195 200 maaliAani.Play(); 196 201 MessageDisplay.Add("mainasit timantin!"); 197 198 202 tahti.Destroy(); 199 203 } … … 219 223 } 220 224 } 221 222 223 225 226 227 -
2013/24/AtteK/hypelypeli/hypelypeli/hypelypeliContent/kentta1.txt
r4107 r4126 15 15 ################################################################################################################################## 16 16 ################################################################################################################################## 17 ####################################################### ###########################################################################18 ####################################################### ###########################################################################19 ######################################################### #########################################################################20 ############################################# ################################## ############################################21 ########################################### 22 ########################################### * * * ** ##### #### ##########17 #######################################################hh################kk####################################################### 18 #######################################################hhhhh#########################rr#######################hhhh################ 19 #########################################################hhh#######################rrrrrrrr####################################### 20 ############################################# ##################################rrr######################################### 21 ########################################### rrr ######### ########## 22 ########################################### * * * ** #####hh## ########## 23 23 ########################################### ################## * ## ######### *********########## 24 ################################# ############################ ####### %%##########25 ######################### ######## ############################# * ####################26 ################################# ########### ############################ #######################27 ####################### #********* ########rrr################################# ** ** ########################28 ######################## ********* ###########rrrrrr###################################### ## ## ##########################29 ########################S ********N ######################################################### ###########################24 ################################# ############################ ################### 25 #########################kkk#### ############################# * #################### 26 ################################# ###########rrrr######################## ####rr################# 27 ####################### ########rrr#####rrr########hhh############## ** ** ##rrrrr################# 28 ######################## ###########rrrrrr######r#######hhhhh################### ## ## ######rrr################# 29 ########################S N ######################################################### ########################### 30 30 #########################################hhh###################################################################################### 31 ##########################################h################################################# ######################################31 ##########################################h#################################################kkk################################### 32 32 ################################################################################################################################## 33 33 ################################################################################################################################## -
2013/24/AtteK/hypelypeli/hypelypeli/hypelypeliContent/kentta2.txt
r4107 r4126 6 6 ###############S # *** ##### 7 7 ########################### N ************ ######################################### ### ##### 8 ####################################################### #### ############ ########################## ############### ###############################################%%#####9 ################################## ##################### #* ######################################### ######################################################10 #################################### ################################## ######### #########################################*** *######################################################8 ####################################################### #### ############ ##########################rrrr########### ###################################################### 9 ##################################rrrr################# #* ###########################rrr########### ###################################################### 10 ####################################rrr############################### ######### ############################rr###########*** *###################################################### 11 11 ############################################################################################ ################################* ###################################################### 12 12 ################################################################################################################### ################################ ###################################################### 13 ################################################################################################################### ** 14 ################################################################################################################### ### 15 ################################################################################################################### ######################### 13 ################################################################################################################### ** ## ###################################################### 14 ################################################################################################################### ### ##hh## ###################################################### 15 ################################################################################################################### ######################### ####### ###################################################### 16 16 ################################################################################################################### ######################### ###################################################### 17 17 ################################################################################################################### #################################################################################################### -
2013/24/AtteK/hypelypeli/hypelypeli/hypelypeliContent/kentta3.txt
r4107 r4126 1 1 # 2 2 # * 3 ## ** * * *4 # ## # # ######## # * *3 # ** * * * 4 ## # # ######## # * * 5 5 ################################## # # 6 6 ################################## *
Note: See TracChangeset
for help on using the changeset viewer.