Cov txheej txheem:
Video: Floppy Bird: 3 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:25
Hnub no peb yuav ua game siv TFT LCD. Qhov no yuav zoo li kev ua si uas yog nrov tiag tiag thiab ntau tus neeg tseem ua qhov kev ua si no. Qhov kev ua si hu ua Flappy Bird tab sis qhov kev ua si no txawv me ntsis vim tias UI sib txawv raws li qhov kev ua si ua haujlwm li cas. Kuv hu qhov kev ua si Floppy Bird vim qhov no tuaj yeem ua rau muaj teeb meem kev cai lij choj. Txawm li cas los xij nws yog kev ua si lom zem tiag tiag thiab nws yooj yim los ua. Kuv tau ua cov lus qhia no uas yuav tso cai rau koj ua qhov kev ua si kom tiav thiab ua kom nws ua haujlwm zoo li kuv tau ua. Yog tias koj muaj lus nug ces thov tawm hauv qab no thiab kuv yuav sim teb cov lus nug no kom sai li sai tau.
Khoom siv
- Arduino Mega 2560 thiab cable
- Arduino Mega Shield
- Arduino TFT LCD Tau tshaj nrog Arduino Mega 2560
- SD daim npav
Kauj Ruam 1: Sib dhos TFT LCD
Tam sim no, peb tuaj yeem pib sau cov TFT LCD. Peb yuav txuas TFT LCD mus rau daim ntaub thaiv, yog li ua ntej coj TFT LCD thiab pib kho nws nrog cov pins ntawm daim ntaub thaiv. Thaum koj tau ua raws cov pins, thawb TFT LCD qis kom nws haum rau hauv qhov chaw. Thaum txhua tus pin taub hau nyob hauv daim thaiv thiab koj tsis tuaj yeem pom tus pin taub hau, yog thaum koj paub tias TFT LCD txuas nrog kom raug. Tom ntej no, peb tuaj yeem ntsaws rau hauv daim thaiv rau Arduino Mega 2560. Kho tus pin ntawm daim ntaub thaiv ntawm Arduino Mega thiab ntsaws rau hauv. Thaum txhua tus pin taub hau nyob hauv Arduino Mega thiab koj tsis tuaj yeem pom tus pin taub hau, uas yog thaum koj paub tias TFT LCD tau txuas nrog kom raug thiab nws tau npaj los ua haujlwm. Txuas rau hauv Arduino kom pom tias koj tau txuas nrog LCD kom raug, yog tias lub LCD tig rau thiab lub vijtsam yog dawb ces zoo siab, koj tau ua tiav txuas nrog TFT LCD thiab tam sim no nws tau npaj los ua haujlwm. Thaum kawg, peb muaj ib yam ua, uas yog txuas SD daim npav hauv LCD. Nyob tom qab ntawm TFT LCD muaj daim npav SD qhov uas koj tuaj yeem ntsaws daim npav SD. Yog li ntawd, tsuas yog ntsaws nws thiab nws ua tiav.
Kauj ruam 2: Programming TFT LCD
Tam sim no, peb yuav teeb tsa lub LCD yog li nws tau ua si thiab peb tuaj yeem ua nws. Hauv qab no yog cov cai uas koj yuav tsum tau suav sau thiab xa tawm siv Arduino IDE.
Teeb meem koj yuav muaj:
Hloov qhov ntsuas ntawm TFT LCD raws li tus qauv koj muaj.
TUAJ CODE:
#include #include #include
// ==== Tsim Cov Hom Phiaj
UTFT myGLCD (ILI9341_16, 38, 39, 40, 41); // Cov ntsuas yuav tsum tau hloov kho rau koj Cov Zaub/Shield qauv URTouch myTouch (6, 5, 4, 3, 2);
// ==== Txhais Fonts
sab nrauv uint8_t SmallFont ; sab nrauv uint8_t BigFont ; sab nrauv uint8_t SevenSegNumFont ;
sab nrauv tsis tau kos npe rau noog 01 [0x41A]; // Noog Bitmap
koj x, y. // Variables rau kev tswj hwm qhov twg cov zaub tau raug nias
// Noog noog
pem x = 319; int yP = 100; int yB = 50; int txavRate = 3; int fallRateInt = 0; ntab fallRate = 0; int tau = 0; int lastSpeedUpScore = 0; int siab tshaj plaws; boolean screenPressed = tsis tseeb; boolean gameStarted = tsis tseeb;
void teeb tsa () {
// Pib tso saib myGLCD. InitLCD (); myGLCD.clrScr (); myTouchInitTouch (); myTouch.setPrecision (PREC_MEDIUM); qhab nia siab tshaj = EEPROM.read (0); // Nyeem cov qhab nia siab tshaj los ntawm EEPROM pib game (); // Pib qhov kev ua si}
void voj () {
xP = xP-movingRate; // xP - x kev koom tes ntawm cov pilars; range: 319 - (-51) drawPilars (xP, yP); // Kos tus ncej // yB - y sib koom ntawm cov noog uas nyob ntawm tus nqi ntawm qhov poob qis nce yB+= fallRateInt; fallRate = fallRate+0.4; // Txhua qhov inetration qhov poob qis nce ntxiv kom peb tuaj yeem cuam tshuam qhov nrawm/ nqus lub ntiaj teb fallRateInt = int (fallRate); // Txheeb xyuas kev sib tsoo yog tias (yB> = 180 || yB <= 0) {// gameOver saum thiab hauv qab (); } yog ((xP = 5) && (yB <= yP-2)) {// sab saud gameOver (); } yog ((xP = 5) && (yB> = yP+60)) {// qis dua gameOver (); } // Kos tus noog drawBird (yB);
// Tom qab tus ncej tau dhau los ntawm qhov screen
yog (xPRESET = 250) && (x = 0) && (y = 0) && (x = 30) && (y = 270) {myGLCD.setColor (0, 200, 20); myGLCD.fillRect (318, 0, x, y-1); myGLCD.setColor (0, 0, 0); myGLCD.drawRect (319, 0, x-1, y);
myGLCD.setColor (0, 200, 20);
myGLCD.fillRect (318, y+81, x, 203); myGLCD.setColor (0, 0, 0); myGLCD.drawRect (319, y+80, x-1, 204); } lwm tus yog (x <= 268) {// Kos lub duab plaub xiav txoj cai ntawm tus ncej myGLCD.setColor (114, 198, 206); myGLCD.fillRect (x+51, 0, x+60, y); // Kos tus ncej myGLCD.setColor (0, 200, 20); myGLCD.fillRect (x+49, 1, x+1, y-1); // Kos cov kab dub ntawm tus ncej myGLCD.setColor (0, 0, 0); myGLCD.drawRect (x+50, 0, x, y); // Kos lub duab plaub xiav sab laug ntawm tus ncej myGLCD.setColor (114, 198, 206); myGLCD.fillRect (x-1, 0, x-3, y);
// Tus ncej qab
myGLCD.setColor (114, 198, 206); myGLCD.fillRect (x+51, y+80, x+60, 204); myGLCD.setColor (0, 200, 20); myGLCD.fillRect (x+49, y+81, x+1, 203); myGLCD.setColor (0, 0, 0); myGLCD.drawRect (x+50, y+80, x, 204); myGLCD.setColor (114, 198, 206); myGLCD.fillRect (x-1, y+80, x-3, 204); } // Kos tus qhab nia myGLCD.setColor (0, 0, 0); myGLCD.setBackColor (221, 216, 148); myGLCD.setFont (BigFont); myGLCD.printNumI (qhab nia, 100, 220); }
// ====== drawBird () - Kev ua haujlwm tshwj xeeb
void drawBird (int y) {// Kos tus noog - bitmap myGLCD.drawBitmap (50, y, 35, 30, bird01); // Kos cov duab plaub xiav saum toj thiab hauv qab tus noog txhawm rau txhawm rau tshem nws lub xeev previus myGLCD.setColor (114, 198, 206); myGLCD.fillRoundRect (50, y, 85, y-6); myGLCD.fillRoundRect (50, y+30, 85, y+36); } // ======== gameOver () - Kev ua haujlwm tsis muaj nuj nqis gameOver () {ncua sijhawm (3000); // 1 thib ob // Tshem qhov screen thiab luam tawm cov ntawv myGLCD.clrScr (); myGLCD.setColor (255, 255, 255); myGLCD.setBackColor (0, 0, 0); myGLCD.setFont (BigFont); myGLCD.print ("GAME OVER", CENTER, 40); myGLCD.print ("Score:", 100, 80); myGLCD.printNumI (qhab nia, 200, 80); myGLCD.print ("Rov pib dua …", CENTER, 120); myGLCD.setFont (SevenSegNumFont); myGLCD.printNumI (2, CENTER, 150); ncua (1000); myGLCD.printNumI (1, CENTER, 150); ncua (1000); // Sau tus qhab nia siab tshaj hauv EEPROM yog (qhab nias> siab tshaj plaws) {siab tshaj qhov qhab nias = qhab nia; EEPROM.write (0, qhov qhab nia siab tshaj); } // Pib dua qhov hloov pauv los pib txoj haujlwm qhov tseem ceeb xP = 319; yB = 50; fallRate = 0; tau = 0; lastSpeedUpScore = 0; txavRate = 3; gameStarted = tsis tseeb; // Rov pib ua si pib gameGame (); }
Kauj ruam 3: Ua tiav
Peb tau ua qhov Circuit Court thiab suav sau cov cai. Tam sim no, peb tsuas yog yuav tsum ntsaws rau hauv Arduino mega thiab ua si game.
Ntawm no, Kuv muaj qhov txuas rau daim vis dis aus uas qhia tias qhov kev ua si no ua haujlwm li cas thiab yuav ua dab tsi thiaj li teeb tsa nws:
drive.google.com/file/d/18hKQ8v2w2OkM_std-…
Qhia rau kuv paub yog tias koj muaj teeb meem hauv qab no.
Pom zoo:
Floppy Disk IR Camera Hack: 8 Kauj Ruam (nrog Duab)
Floppy Disk IR Camera Hack: Rau xya xyoo dhau los, Kuv tau tawg lub koob yees duab digital dag ib puag ncig. Nws tseem muaj peev xwm thaij duab, tab sis nws yuav luag tsis siv los ntawm qhov screen tawg. Qhov teeb meem tseem ceeb yog tias qee zaum cov ntawv qhia zaub mov yuav yuam kev
Arduino Flappy Bird - Arduino 2.4 "TFT Touchscreen SPFD5408 Bird Game Project: 3 Kauj Ruam
Arduino Flappy Bird | Arduino 2.4 "TFT Touchscreen SPFD5408 Bird Game Project: Flappy Bird yog qhov kev ua si nrov dhau los nyob rau ob peb xyoos thiab ntau tus neeg tsim nws hauv thier tus kheej txoj kev yog li kuv, Kuv tsim kuv li version ntawm flappy noog nrog Arduino thiab pheej yig 2.4" TFT Touchscreen SPFD5408, Yog li cia peb pib ua
Kev Ntsuas Tus Kheej rau Cov Neeg Hlau Tsheb Siv Stepper Motor ntawm Old Floppy/CD Drive: 8 Cov Kauj Ruam (nrog Duab)
Kev Ntsuas Tus Kheej rau Cov Neeg Hlau Tsheb Siv Stepper Motor ntawm Old Floppy/CD Drive: Ntse tswj lub zog rau cov neeg hlau tsheb Koj puas txhawj xeeb ua lub hauv paus zoo rau koj lub tsheb neeg hlau? Nov yog qhov kev daws teeb meem zoo tshaj plaws tsuas yog siv koj lub qub floppy/ CD/ DVD drives. saib nws tawm thiab tau txais lub tswv yim ntawm nwsVisit georgeraveen.blogspot.com
Apple II Floppy Hackintosh I7-7700 3.6Ghz: 7 Kauj Ruam
Apple II Floppy Hackintosh I7-7700 3.6Ghz: Thawj daim duab no yog muab rau koj siv rau kev tsav tsheb tsis zoo (nrog tus thawj Apple zaj duab xis zaj sawv), kuv lub tsheb muaj me ntsis ntxiv rau nws. Daim duab thib ob yog sab hauv, Kuv tsis nco qab thaij ib daim duab ua ntej kuv tau muab nws tshem tawm, yog li kev hwm ntawm Goog
Amiga Arduino Floppy Drive Case/Enclosure: 5 Kauj Ruam
Amiga Arduino Floppy Drive Case/Enclosure: Cov lus qhia no piav qhia yuav ua li cas sib dhos cov ntaub ntawv ntim rau lub Arduino Amiga Floppy Disk Reader/Writer rau Windows project. Ua kom tiav txoj haujlwm no koj yuav xav tau: Ib lub tshuab luam ntawv 3DThe Arduino pro mini thiab FTDI breakout board piav qhia pe ab