Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
De_Struktor
unregistriert
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
protected override void LoadContent() { // Create a new SpriteBatch, whichcan be used to draw textures. allPic_rect[0] = new Rectangle(30, 30, 30, 30); allPic_rect[1] = new Rectangle(30, 30, 30, 30); allPic_rect[2] = new Rectangle(30, 30, 30, 30); allPic[0] = Content.Load<Texture2D>("Spieler_statisch"); allPic[1] = Content.Load<Texture2D>("Spieler_rechts"); allPic[2] = Content.Load<Texture2D>("hinten_hero"); allPic[3] = Content.Load<Texture2D>("constblock"); allPic[4] = Content.Load<Texture2D>("bombableblock"); allPic[5] = Content.Load<Texture2D>("Bomb1"); allPic[6] = Content.Load<Texture2D>("invisibleWall"); allPic[7] = Content.Load<Texture2D>("explosion");protected override void Update(GameTime gameTime) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit(); timerDurrate += gameTime.ElapsedGameTime.TotalMilliseconds; //Die Zeit die vom vergangenen Drawcall vergangen ist, hinzufügen if (timerDurrate >= currTime) // Falls die gespeicherte Zeit größer ist als der Timer zum Ticken braucht, führ // Anweisung aus bzw. führe ein Ereignis aus { timerDurrate = 0; // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit(); if (Keyboard.GetState().IsKeyUp(Keys.W)) { block = false; } if (Keyboard.GetState().IsKeyUp(Keys.A)) { block2 = false; } if (Keyboard.GetState().IsKeyUp(Keys.S)) { block3 = false; } if (Keyboard.GetState().IsKeyUp(Keys.D)) { block4 = false; } // Hier beginnt die Abfrage für den - W - Knopf if (Keyboard.GetState().IsKeyDown(Keys.W)) { if (!block) { block = true; // allPic_rect[0] = spieler rechts schauend // Spieleranimation nach rechts = allPic[1] if (allPic_rect[0].Y >= 30) { allPic_rect[0].Y -= 30; for (int d = 0; d < 216; d++) { if (constblock_rect[d].Intersects(allPic_rect[0])) { allPic_rect[0].Y += constblock_rect[d].Width; } } for (int d = 0; d < 225; d++) { if (bombableblock_rect[d].Intersects(allPic_rect[0])) { allPic_rect[0].Y += bombableblock_rect[d].Width; } } } } } else if (Keyboard.GetState().IsKeyDown(Keys.A)) { if (!block2) { block2 = true; if (allPic_rect[0].X >= 30) { allPic_rect[0].X -= 30; } for (int c = 0; c < 216; c++) { if (constblock_rect[c].Intersects(allPic_rect[0])) { allPic_rect[0].X -= constblock_rect[c].Height; } } for (int c = 0; c < 225; c++) { if (bombableblock_rect[c].Intersects(allPic_rect[0])) { allPic_rect[0].X += bombableblock_rect[c].Height; } } } } else if (Keyboard.GetState().IsKeyDown(Keys.S)) { if (!block3) { block3 = true; if (allPic_rect[0].Y <= winValue[5] - 70) { allPic_rect[1].Y += 30; } if (Keyboard.GetState().IsKeyUp(Keys.D)) { } for (int o = 0; o < 216; o++) { if (constblock_rect[o].Intersects(allPic_rect[0])) { allPic_rect[0].X -= constblock_rect[o].Height; } } for (int c = 0; c < 225; c++) { if (bombableblock_rect[c].Intersects(allPic_rect[0])) { allPic_rect[0].Y -= bombableblock_rect[c].Height; } } } } else if (Keyboard.GetState().IsKeyDown(Keys.D)) { if (!block4) { block4 = true; // block 4 = Tasten - D - ist gedrückt if (allPic_rect[0].X <= winValue[4] - 70) { allPic_rect[0].X += 30; } for (int i = 0; i < 216; i++) { if (constblock_rect[i].Intersects(allPic_rect[0])) { allPic_rect[0].X -= constblock_rect[i].Width; } } for (int c = 0; c < 225; c++) { if (bombableblock_rect[c].Intersects(allPic_rect[0])) { allPic_rect[0].X -= bombableblock_rect[c].Width; } } base.Update(gameTime); } } } }[/i][/i] [i][i]// die allPic[0]) sind arrays, welche ich immer für verschiedene texturen benutze um nicht immer den vollständigen namen umändern zu müssen.[/i][/i] [i]// ich bin mit den arrays immer gut klar gekommen[/i] [i] [/i] [i] [/i] |
Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von »BlueCobold« (05.03.2013, 15:44)
De_Struktor
unregistriert
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
protected override void LoadContent() { // Create a new SpriteBatch, whichcan be used to draw textures. allPic_rect[0] = new Rectangle(30, 30, 30, 30); allPic_rect[1] = new Rectangle(30, 30, 30, 30); allPic_rect[2] = new Rectangle(30, 30, 30, 30); allPic[0] = Content.Load<Texture2D>("Spieler_statisch"); allPic[1] = Content.Load<Texture2D>("Spieler_rechts"); allPic[2] = Content.Load<Texture2D>("hinten_hero"); allPic[3] = Content.Load<Texture2D>("constblock"); allPic[4] = Content.Load<Texture2D>("bombableblock"); allPic[5] = Content.Load<Texture2D>("Bomb1"); allPic[6] = Content.Load<Texture2D>("invisibleWall"); allPic[7] = Content.Load<Texture2D>("explosion");protected override void Update(GameTime gameTime) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit(); timerDurrate += gameTime.ElapsedGameTime.TotalMilliseconds; //Die Zeit die vom vergangenen Drawcall vergangen ist, hinzufügen if (timerDurrate >= currTime) // Falls die gespeicherte Zeit größer ist als der Timer zum Ticken braucht, führ // Anweisung aus bzw. führe ein Ereignis aus { timerDurrate = 0; // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit(); if (Keyboard.GetState().IsKeyUp(Keys.W)) { block = false; } if (Keyboard.GetState().IsKeyUp(Keys.A)) { block2 = false; } if (Keyboard.GetState().IsKeyUp(Keys.S)) { block3 = false; } if (Keyboard.GetState().IsKeyUp(Keys.D)) { block4 = false; } // Hier beginnt die Abfrage für den - W - Knopf if (Keyboard.GetState().IsKeyDown(Keys.W)) { if (!block) { block = true; // allPic_rect[0] = spieler rechts schauend // Spieleranimation nach rechts = allPic[1] if (allPic_rect[0].Y >= 30) { allPic_rect[0].Y -= 30; for (int d = 0; d < 216; d++) { if (constblock_rect[d].Intersects(allPic_rect[0])) { allPic_rect[0].Y += constblock_rect[d].Width; } } for (int d = 0; d < 225; d++) { if (bombableblock_rect[d].Intersects(allPic_rect[0])) { allPic_rect[0].Y += bombableblock_rect[d].Width; } } } } } else if (Keyboard.GetState().IsKeyDown(Keys.A)) { if (!block2) { block2 = true; if (allPic_rect[0].X >= 30) { allPic_rect[0].X -= 30; } for (int c = 0; c < 216; c++) { if (constblock_rect[c].Intersects(allPic_rect[0])) { allPic_rect[0].X -= constblock_rect[c].Height; } } for (int c = 0; c < 225; c++) { if (bombableblock_rect[c].Intersects(allPic_rect[0])) { allPic_rect[0].X += bombableblock_rect[c].Height; } } } } else if (Keyboard.GetState().IsKeyDown(Keys.S)) { if (!block3) { block3 = true; if (allPic_rect[0].Y <= winValue[5] - 70) { allPic_rect[1].Y += 30; } if (Keyboard.GetState().IsKeyUp(Keys.D)) { } for (int o = 0; o < 216; o++) { if (constblock_rect[o].Intersects(allPic_rect[0])) { allPic_rect[0].X -= constblock_rect[o].Height; } } for (int c = 0; c < 225; c++) { if (bombableblock_rect[c].Intersects(allPic_rect[0])) { allPic_rect[0].Y -= bombableblock_rect[c].Height; } } } } else if (Keyboard.GetState().IsKeyDown(Keys.D)) { if (!block4) { block4 = true; // block 4 = Tasten - D - ist gedrückt if (allPic_rect[0].X <= winValue[4] - 70) { allPic_rect[0].X += 30; } for (int i = 0; i < 216; i++) { if (constblock_rect[i].Intersects(allPic_rect[0])) { allPic_rect[0].X -= constblock_rect[i].Width; } } for (int c = 0; c < 225; c++) { if (bombableblock_rect[c].Intersects(allPic_rect[0])) { allPic_rect[0].X -= bombableblock_rect[c].Width; } } base.Update(gameTime); } } } } |
De_Struktor
unregistriert
De_Struktor
unregistriert
De_Struktor
unregistriert
Werbeanzeige