Project tutorial
Catch The Circles!

Catch The Circles! © GPL3+

A new, easy to make, easy to play game, using almost any Arduino, 5110 LCD, and a joystick!

  • 1,871 views
  • 0 comments
  • 3 respects

Components and supplies

About this project

Hi there, my name is Arash and it's the first story that I upload. My English is not so great and also my coding, my specialty is hardware, and I know how to code but it's not that organized and professional that it should be so excuse me for any possible mistake, please correct them and let me know them.

So, it's a simple game I've made using Arduino, a 1.6" 5110 LCD and a joystick from 1:00 AM to 2:30 AM, so anyone can do it, faster and better. Feel free to do any change in codes, hardware, using them, publishing them in any way you like. You can also add some voice to it (it's not as easy as it sounds) and much more.

The game principle is so easy, in the beginning you have 10000 score, an small circle controlled by your joystick and another bigger circle that you have to catch by moving yours over it! pretty much that's it, also if you don't catch it in an specific time its position will change and you will get negative points, and by catching more points speed of game increases but if you lose points down to 10000 it will be reset again. the game ends in three ways, you loose all your points, the T.O that means you've ran out of time, or reaching 20500 that's nearly impossible!

Code

CactchTheCircle Arduino
The library is here:
http://www.rinkydinkelectronics.com/library.php?id=47
#include <LCD5110_Graph.h>

LCD5110 myGLCD(7,6,5,3,4);

extern uint8_t SmallFont[];
extern unsigned char TinyFont[];
int sc=10000;
int to=10000;
int rc=0;
double xa=0;
int a, b;


void setup()
{
  myGLCD.InitLCD();
  myGLCD.setFont(TinyFont);
  randomSeed(analogRead(7));
  rc = sc;  //record = 10000
}



void loop()
{

if(sc>rc)
rc=sc;  // increase th record 

if(sc<=10000) //reseting record to reset speed
rc=sc;


  myGLCD.clrScr();
  myGLCD.drawRect(0, 0, 83, 47);

if(xa == 0)
{
  a=random(0,83);
  b=random(0,47);
if(rc>0&&rc<11000) //seting the speed
xa=150;
if(rc>11000&&rc<12000)
xa=130;
if(rc>12000&&rc<13000)
xa=100;
if(rc>13000&&rc<14000)
xa=65;
if(rc>14000&&rc<15000)
xa=45;
if(rc>15000&&rc<17000)
xa=35;
if(rc>17000&&rc<19000)
xa=25;
if(rc>20000)
xa=20;
}
  xa--; 
  

  

  myGLCD.print("Score ", LEFT, 0);
  myGLCD.print(String(sc), 22, 0);

  if(sc>=15000&&sc<16000)
  {
  myGLCD.print("not bad.", RIGHT , 0);
  }

  if(sc>=16000&&sc<17000)
  {
  myGLCD.print("Good!", RIGHT , 0);
  }

  
if(sc>=17000&&sc<19000)  {
  myGLCD.print("MY BOY!", RIGHT , 0);
  }

  
  if(sc>=19000)
  {
  myGLCD.print("WOW!!", RIGHT , 0);
  }
  myGLCD.drawCircle(a,b,3);
  myGLCD.drawCircle(a,b,4);
  myGLCD.drawCircle(a,b,5);
  
  myGLCD.drawCircle(map(analogRead(A1),0,1024,0,83),map(analogRead(A0),0,1024,0,47),1);
  myGLCD.drawCircle(map(analogRead(A1),0,1024,0,83),map(analogRead(A0),0,1024,0,47),3);
  myGLCD.drawCircle(map(analogRead(A1),0,1024,0,83),map(analogRead(A0),0,1024,0,47),4);


  if(xa == 0)   //loosing one round
{
sc -= 150;
}

if(map(analogRead(A1),0,1024,0,83)<a+5&&map(analogRead(A1),0,1024,0,83)>a-5 &&  map(analogRead(A0),0,1024,0,47)<b+5&& map(analogRead(A0),0,1024,0,47)>b-5) // winning one round
{
    xa=0;
    sc+=100;
}


if(sc<=0)  // Game over
while(1)
{
    myGLCD.clrScr();
  myGLCD.setFont(SmallFont);
  myGLCD.print("game over!", CENTER, 32);
    myGLCD.update();

}

if(sc>=20500)  // WIN!! (IMPOSSIBLE : )) ) 
while(1)
{
    myGLCD.clrScr();
  myGLCD.setFont(SmallFont);
  myGLCD.print("WINNER!!", CENTER, 24);
  myGLCD.print("WHO THE HELL", CENTER, 32);
  myGLCD.print("ARE YOU?!", CENTER, 40);
    myGLCD.update();

}

if(to==0)  // (time out)
while(1)
{
  myGLCD.clrScr();
  myGLCD.setFont(SmallFont);
  myGLCD.print("T.O! record:", CENTER, 32);
  myGLCD.print(String(sc), CENTER, 40);

  myGLCD.update();

}


  myGLCD.update();
  to --;   // timer decrease
  delay(10);  

}

Schematics

connections diagram
connections are easy to change using the code,
joystick has two analog outputs and LCD pins can be changed also within the code.
LCD -> Arduino:
VCC -> Arduino 5V
LIGHT(LED, BL or BACKLIGHT) -> Arduino 5V
GND -> Arduino GND
CLK (SCLK) -> Arduino pin 7
DIN (DN or MOSI) -> Arduino pin 6
DC (D/C) -> Arduino pin 5
CE (SCE or CS) -> Arduino pin 4
RST (RESET) -> Arduino pin 3

JOYSTICK -> Arduino:
GND -> Arduino GND
5V -> Arduino 5V
VRX -> A1
VRY -> A0
Untitled

Comments

Similar projects you might like

LED light "Whack-a-mole"

Project tutorial by courtlandjensen

  • 3,692 views
  • 4 comments
  • 14 respects

Digital Setting Circles for Telescope

Project tutorial by 3wheels

  • 1,946 views
  • 0 comments
  • 5 respects

Mega Bread - Atari Joystick Linking for Robotics Control

Project in progress by Pigeon-Kicker

  • 1,716 views
  • 3 comments
  • 10 respects

Arduino Game By LCD

Project tutorial by Mohammed Magdy

  • 32,868 views
  • 31 comments
  • 108 respects

Pinball Sounds and Music

Project tutorial by Bob Blomquist

  • 5,999 views
  • 3 comments
  • 18 respects

Ninja Dollar - LCD game

Project tutorial by anime

  • 2,356 views
  • 2 comments
  • 4 respects
Add projectSign up / Login