NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io


#include "U8glib.h"

//== KUTUPKANE AYARLARI ==
U8GLIB_PCD8544 u8g(8, 9, 11, 10, 12); // SPI Com: SCK = 8, MOSI = 9, CS = 11, DO = 10, Reset = 12
int KONTROL1 = A1; // 1. OYUNCU POTANS PINI
int KONTROL2 = A0; // 2. OYUNCU POTANS PINI
int KAZANMA_SAYISI = 3; // OYUN KAZANMA PUANI
byte SES = 2; // SES ÇIKIŞ PINI
int TOP_HIZI = 50; // TOP HIZI

//== DEGISKENLER ==
u8g_uint_t SAHA_EN, SAHA_BOY, YARIMSAHA_EN;
u8g_uint_t TOP_BOYUT = 4;
u8g_uint_t TOPX;
u8g_uint_t TOPYONX = 1;
u8g_uint_t TOPY;
u8g_uint_t TOPYONY = 1;
u8g_uint_t KONTROL_EN = 2;
u8g_uint_t KONTROL_BOY = 8;
u8g_uint_t KONTROLYARIM_BOY = KONTROL_BOY/2;
u8g_uint_t KONTROL0Y;
u8g_uint_t KONTROL1Y;

int PUAN0, PUAN1;
bool OYUN_BITTI = false;

int CARPMA_TONU = 523;
int CARPMA_SES_SURE = 62;
int ISKA_TONU = 523 / 2;
int ISKA_SES_SURE = 512;

unsigned long OYUN_ZAMAN;
int ANIMASYON_HIZI = TOP_HIZI;

bool KAYBEDEN_TARAF(u8g_uint_t py) // KAYBEDENI BELIRLE
{
u8g_uint_t TOPTop = TOPY;
u8g_uint_t TOPBottom = TOPY + TOP_BOYUT - 1;
u8g_uint_t KONTROLTop = py;
u8g_uint_t KONTROLBottom = py + KONTROL_BOY - 1;
return TOPBottom < KONTROLTop || TOPTop > KONTROLBottom;
}

void PUAN_YAZ() // PUAN HESAPLA
{
char strPUAN0[] = "?";
char strPUAN1[] = "?";
strPUAN0[0] = '0' + PUAN0;
strPUAN1[0] = '0' + PUAN1;
u8g.setFont(u8g_font_04b_03b);
u8g_uint_t PUAN_EN = u8g.getStrPixelWidth(strPUAN0);
const int offset = 5;
u8g_uint_t PUANY = 9;
u8g.drawStr( YARIMSAHA_EN - offset - PUAN_EN, PUANY, strPUAN0);
u8g.drawStr( YARIMSAHA_EN + offset, PUANY, strPUAN1);
}

void OYUN_BITTI_YAZ() // OYUN BITTI YAZISINI YAZ
{
u8g.setFont(u8g_font_timB18);
u8g.setFontPosCenter(); // vertical alignment
char gameStr[] = "OYUN";
char overStr[] = "BITTI";
u8g_uint_t gx = (SAHA_EN - u8g.getStrPixelWidth(gameStr)) / 2;
u8g_uint_t ox = (SAHA_EN - u8g.getStrPixelWidth(overStr)) / 2;
u8g.drawStr(gx, 20, gameStr);
u8g.drawStr(ox, 40, overStr);
}

void KORT_CIZ() // SAHA KENARLARINI CIZ
{
u8g.drawHLine(0, 0, SAHA_EN);
u8g.drawHLine(0, SAHA_BOY - 1, SAHA_EN);
byte dash = 3;
for (byte y = 0; y < (SAHA_BOY / dash / 2); y++)
{
u8g.drawVLine(YARIMSAHA_EN - 1, 2 + y * dash * 2, dash);
}
}

void OYUNCU1_KAYBETTI() // TOP ISKALANIRSA PUAN ARTTIR
{

TOPX = SAHA_EN - TOP_BOYUT - 1;
TOPY = KONTROL1Y + KONTROLYARIM_BOY;
tone(SES, ISKA_TONU, ISKA_SES_SURE);
delay(1000);
PUAN1++;
ANIMASYON_HIZI = TOP_HIZI;
if (PUAN1 == KAZANMA_SAYISI) OYUN_BITTI = true;
}

void OYUNCU2_KAYBETTI() // TOP ISKALANIRSA PUAN ARTTIR
{

TOPX = 1;
TOPY = KONTROL0Y + KONTROLYARIM_BOY;
tone(SES, ISKA_TONU, ISKA_SES_SURE);
delay(1000);
PUAN0++;
ANIMASYON_HIZI = TOP_HIZI;
if (PUAN0 == KAZANMA_SAYISI) OYUN_BITTI = true;
}

void TOP_YONU() // CARPMA SONRASI TOP YONUNU BELIRLE
{
tone(SES, CARPMA_TONU, CARPMA_SES_SURE);
TOPYONX = -TOPYONX;
ANIMASYON_HIZI--;
}

void TOP_HAREKET()
{
if (millis() > OYUN_ZAMAN) { // ZAMAN UZADIKCA TOP HIZINI ARTTIR
TOPX += TOPYONX;
if (TOPX <= 0)
if (KAYBEDEN_TARAF(KONTROL0Y)) OYUNCU1_KAYBETTI(); else TOP_YONU();

if (TOPX >= (SAHA_EN - TOP_BOYUT))
if (KAYBEDEN_TARAF(KONTROL1Y)) OYUNCU2_KAYBETTI(); else TOP_YONU();

TOPY += TOPYONY;
if (TOPY >= (SAHA_BOY - TOP_BOYUT) || TOPY <= 0) {
TOPYONY = -TOPYONY;
ANIMASYON_HIZI--;
tone(SES, CARPMA_TONU, CARPMA_SES_SURE);
}

OYUN_ZAMAN = millis() + ANIMASYON_HIZI;
}
}

void KONTROL_YAZ(u8g_uint_t KONTROLX, int KONTROLY)
{
u8g.drawBox(KONTROLX, KONTROLY, KONTROL_EN, KONTROL_BOY);
}

void KONTROL_CIZ()
{
KONTROL0Y = map(analogRead(KONTROL1), 0, 1023, 0, SAHA_BOY - KONTROL_BOY);
KONTROL1Y = map(analogRead(KONTROL2), 0, 1023, 0, SAHA_BOY - KONTROL_BOY);

KONTROL_YAZ(0, KONTROL0Y);
KONTROL_YAZ(SAHA_EN - KONTROL_EN, KONTROL1Y);
}

void setup(void) {
// SAHA CIZIM
u8g.setRot180();
SAHA_EN = u8g.getWidth();
SAHA_BOY = u8g.getHeight();
YARIMSAHA_EN = SAHA_EN / 2; // SAHA ORTA CIZGISI
}

void loop(void) {
u8g.firstPage();
do {

if (OYUN_BITTI)
OYUN_BITTI_YAZ();
else
TOP_HAREKET(); // TOPU HAREKET ETTIR
KORT_CIZ();// KORTU CIZ
PUAN_YAZ(); // PUANI YAZ
u8g.drawBox(TOPX, TOPY, TOP_BOYUT, TOP_BOYUT);
KONTROL_CIZ(); // KONTRO CUBUKLARINI CIZ
} while ( u8g.nextPage() );
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.