Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // https://youtu.be/oyisl88HAxE
- // https://www.youtube.com/@LeventeDaradici/videos
- // This file belongs to code called ARDUINO GAME ON TV - PLANE
- // file name: PlaneTvOUT.ino
- //
- #include <TVout.h>
- #include <fontALL.h>
- #include "plane.h"
- #include "plane4.h"
- #include "cloud.h"
- #include "level1.h"
- #include "level2.h"
- #include "level3.h"
- #include "level4.h"
- #include "level5.h"
- #include "level6.h"
- #include "level7.h"
- #include "level8.h"
- #include "level9.h"
- #include "level10.h"
- #include "planelogo.h"
- #include "arduinologo.h"
- #include "youwin.h"
- #include "yourlose.h"
- #include "explozie.h"
- int Up = 5;
- int Down = 2;
- int Left = 4;
- int Right = 3;
- int Push = 6;
- int Start = 8;
- int PlaneX =0;
- int PlaneY = 20;
- int CloudX =80;
- int CloudY = 66;
- int Cloud2X =80;
- int Cloud2Y = 66;
- int RezX = 0;
- int RezY = 50;
- int VitezaNori = 1;
- int Nivel = 1;
- int NumaratoareNivel = 0;
- int Scor = 0;
- int LevelX = 4;
- int LevelY = 0;
- bool AfisareCloud1 = true;
- bool AfisareCloud2 = false;
- TVout TV;
- void setup()
- {
- Serial.begin(9600);
- pinMode(Up, INPUT);
- pinMode(Down, INPUT);
- pinMode(Left, INPUT);
- pinMode(Right, INPUT);
- pinMode(Push, INPUT);
- pinMode(Start, INPUT);
- pinMode(11, OUTPUT);
- TV.begin(NTSC, 128, 96 );
- TV.select_font(font6x8);
- for (RezX = 0; RezX < 50; RezX++)
- {
- RezY = RezY - 1;
- if (RezY < 1) RezY = 1;
- TV.bitmap(RezX, RezY, plane);
- delay(60);
- if (RezY > 1 )
- {
- TV.clear_screen();
- }
- }
- TV.bitmap(0, 58, arduinologo);
- TV.bitmap(0, 38, planelogo);
- delay(3000);
- TV.clear_screen();
- AfiseazaNivelul();
- TV.bitmap(PlaneX, PlaneY, plane4);
- }
- void loop()
- {
- TV.print("SCORE: ");
- TV.println(Scor);
- TV.bitmap(PlaneX, PlaneY, plane4);
- if(digitalRead(Up) == 0)
- {
- PlaneY-=5;
- if (PlaneY < 1) PlaneY = 1;
- }
- if(digitalRead(Down) == 0)
- {
- PlaneY+=5;
- if (PlaneY > 81) PlaneY = 81;
- }
- if (AfisareCloud1)
- {
- CloudX = CloudX-VitezaNori;
- if (CloudX > 0)
- {
- TV.bitmap(CloudX, CloudY, cloud);
- }
- if (CloudX < 0)
- {
- CloudX = 93;
- AfisareCloud1 = false;
- NumaratoareNivel = NumaratoareNivel + 1;
- Scor = Scor + 1;
- }
- if (!AfisareCloud2)
- {
- if (CloudX < 10)
- {
- AfisareCloud2 = true;
- Cloud2Y = random(0,34);
- }
- }
- }
- if (AfisareCloud2)
- {
- Cloud2X = Cloud2X-VitezaNori;
- if (Cloud2X > 0)
- {
- TV.bitmap(Cloud2X, Cloud2Y, cloud);
- }
- if (Cloud2X < 0)
- {
- Cloud2X = 93;
- AfisareCloud2 = false;
- NumaratoareNivel = NumaratoareNivel + 1;
- Scor = Scor + 1;
- }
- if (!AfisareCloud1)
- {
- if (Cloud2X < 10)
- {
- AfisareCloud1 = true;
- CloudY = random(36,75);
- }
- }
- }
- if (NumaratoareNivel == 10)
- {
- Nivel = Nivel + 1;
- VitezaNori = VitezaNori + 1;
- NumaratoareNivel = 0;
- if (Nivel > 10) YouWin();
- if (Nivel > 10) Nivel = 1;
- if (VitezaNori > 10) VitezaNori = 1;
- if (Scor == 100) Scor =0;
- TV.clear_screen();
- AfiseazaNivelul();
- }
- if(PlaneX+14 >= CloudX)
- {
- if(PlaneY <= CloudY && PlaneY+14 >= CloudY)
- {
- YourLose();
- CloudX = 93;
- Cloud2X = 93;
- CloudY = random(36,75);
- Cloud2Y = random(36,75);
- PlaneY = 20;
- }
- }
- if(PlaneX+14 >= Cloud2X)
- {
- if(PlaneY <= Cloud2Y && PlaneY+14 >= Cloud2Y)
- {
- YourLose();
- CloudX = 93;
- Cloud2X = 93;
- CloudY = random(36,75);
- Cloud2Y = random(36,75);
- PlaneY = 20;
- }
- }
- delay(60);
- TV.clear_screen();
- }
- void AfiseazaNivelul()
- {
- for (LevelY = 0; LevelY < 53; LevelY++)
- {
- if (Nivel == 1)
- {
- TV.bitmap(LevelX, LevelY, level1);
- }
- if (Nivel == 2)
- {
- TV.bitmap(LevelX, LevelY, level2);
- }
- if (Nivel == 3)
- {
- TV.bitmap(LevelX, LevelY, level3);
- }
- if (Nivel == 4)
- {
- TV.bitmap(LevelX, LevelY, level4);
- }
- if (Nivel == 5)
- {
- TV.bitmap(LevelX, LevelY, level5);
- }
- if (Nivel == 6)
- {
- TV.bitmap(LevelX, LevelY, level6);
- }
- if (Nivel == 7)
- {
- TV.bitmap(LevelX, LevelY, level7);
- }
- if (Nivel == 8)
- {
- TV.bitmap(LevelX, LevelY, level8);
- }
- if (Nivel == 9)
- {
- TV.bitmap(LevelX, LevelY, level9);
- }
- if (Nivel == 10)
- {
- TV.bitmap(LevelX, LevelY, level10);
- }
- delay(20);
- }
- delay(1000);
- }
- void YouWin()
- {
- TV.clear_screen();
- for (LevelY = 0; LevelY < 53; LevelY++)
- {
- TV.bitmap(LevelX, LevelY, youwin);
- }
- delay(5000);
- }
- void YourLose()
- {
- Explozie();
- TV.clear_screen();
- for (LevelY = 0; LevelY < 53; LevelY++)
- {
- TV.bitmap(LevelX, LevelY, yourlose);
- }
- Nivel = 1;
- Scor = 0;
- VitezaNori = 1;
- NumaratoareNivel = 0;
- delay(5000);
- }
- void Explozie()
- {
- TV.clear_screen();
- TV.bitmap(0, 0, explozie);
- delay(3000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement