Snake hat Tail und Farben angepasst

This commit is contained in:
Julia09055x 2023-12-10 21:05:11 +01:00
parent 72ca020f27
commit 2d953e1e1b

View File

@ -13,67 +13,61 @@ void renderGame(){
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
SDL_RenderClear(renderer); SDL_RenderClear(renderer);
//Head__________________________________________________ SDL_Rect rect; //Rechteck anlegen
SDL_SetRenderDrawColor(renderer, 0, 200, 100, 255); //RGB-Farbe Kopf rect.w = config.blockSizePx; //Breite festlegen
SDL_Rect rect; rect.h = config.blockSizePx; //Höhe festlegen
rect.x = (game.snake.headX * config.blockSizePx); //Abstand links
rect.y = (game.snake.headY * config.blockSizePx); //Abstand rechts
rect.w = config.blockSizePx;
rect.h = config.blockSizePx;
SDL_RenderFillRect(renderer, &rect); //Rechteck rendern //_______Head kreieren__________________________________________________
SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255); //RGB-Farbe Kopf
rect.x = (game.snake.headX * config.blockSizePx); //Abstand links
rect.y = (game.snake.headY * config.blockSizePx); //Abstand rechts
SDL_RenderFillRect(renderer, &rect); //Rechteck rendern
//Snake-Baustein kreieren_________________________________________________________________ //______Tail kreieren_________________________________________________________________
for(int i = 1; i>game.snake.length; i++){ for(int i = 1; i<game.snake.length; i++){
SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255); //RGB-Farbe Tail SDL_SetRenderDrawColor(renderer, 15, 179, 15, 255); //RGB-Farbe Tail
SDL_Rect rect;
rect.x = (game.snake.tail[i][0] * config.blockSizePx); //Abstand links rect.x = (game.snake.tail[i][0] * config.blockSizePx); //Abstand links
rect.y = (game.snake.tail[i][0] * config.blockSizePx); //Abstand rechts rect.y = (game.snake.tail[i][1] * config.blockSizePx); //Abstand rechts
rect.w = config.blockSizePx;
rect.h = config.blockSizePx;
SDL_RenderFillRect(renderer, &rect); //Rechteck rendern SDL_RenderFillRect(renderer, &rect); //Rechteck rendern
} }
//Portal kreieren________________________________________________________________________ //______Portal kreieren________________________________________________________________________
for (int i = 0; i < game.map.portalCount; i++) for (int i = 0; i < game.map.portalCount; i++)
{ {
SDL_SetRenderDrawColor(renderer, 0, 100, 255, 255); //RGB-Farbe Portal //Start-Portal
rect.x = (game.map.portals[i].posX * config.blockSizePx); SDL_SetRenderDrawColor(renderer, 0, 191, 255, 255); //RGB-Farbe Start-Portal
rect.y = (game.map.portals[i].posY * config.blockSizePx); rect.x = (game.map.portals[i].posX * config.blockSizePx);
rect.y = (game.map.portals[i].posY * config.blockSizePx);
SDL_RenderDrawRect(renderer, &rect); //Rechteck rendern SDL_RenderDrawRect(renderer, &rect); //Rechteck rendern
}
//Ausgangs-Portal
SDL_SetRenderDrawColor(renderer, 0, 0, 200, 255); //RGB-Farbe Start-Portal
rect.x = (game.map.portals[i].targetX * config.blockSizePx);
rect.y = (game.map.portals[i].targetY * config.blockSizePx);
SDL_RenderDrawRect(renderer, &rect); //Rechteck rendern
}
//_______Food kreieren_________________________________________________________________________
SDL_SetRenderDrawColor(renderer, 255, 165, 0, 255); //RGB-Farbe Food
rect.x = (game.foodX*config.blockSizePx); //Abstand links
rect.y = (game.foodY* config.blockSizePx); //Abstand rechts
SDL_RenderFillRect(renderer, &rect); //Rechteck rendern
//Food kreieren_________________________________________________________________________ //______Collisions kreieren_________________________________________________________________________
SDL_SetRenderDrawColor(renderer, 255, 0, 255, 255); //RGB-Farbe Food for(int i = 0; i < game.map.collisionCount; i++){
SDL_SetRenderDrawColor(renderer, 112, 128, 144, 255); //RGB-Farbe Wand
rect.x = (game.foodX*config.blockSizePx); //Abstand links
rect.y = (game.foodY* config.blockSizePx); //Abstand rechts
rect.w = config.blockSizePx;
rect.h = config.blockSizePx;
SDL_RenderFillRect(renderer, &rect); //Rechteck rendern
SDL_RenderDrawRect(renderer, &rect); //Rechteck rendern
//Collisions kreieren_________________________________________________________________________
for(int i = 0; i < game.map.collisionCount; i++){
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); //RGB-Farbe Wand
rect.x = (game.map.collisions[i].posX*config.blockSizePx); //Abstand links rect.x = (game.map.collisions[i].posX*config.blockSizePx); //Abstand links
rect.y = (game.map.collisions[i].posY* config.blockSizePx); //Abstand rechts rect.y = (game.map.collisions[i].posY* config.blockSizePx); //Abstand rechts
rect.w = config.blockSizePx;
rect.h = config.blockSizePx;
SDL_RenderFillRect(renderer, &rect); //Rechteck rendern SDL_RenderFillRect(renderer, &rect); //Rechteck rendern
} }
SDL_RenderPresent(renderer); //Fenster aktualisieren SDL_RenderPresent(renderer); //Fenster aktualisieren
} }