Pong for Gamepad2

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PongEngine.h Source File

PongEngine.h

00001 #ifndef PONGENGINE_H
00002 #define PONGENGINE_H
00003 
00004 #include "mbed.h"
00005 #include "N5110.h"
00006 #include "Gamepad.h"
00007 #include "Ball.h"
00008 #include "Paddle.h"
00009 
00010 // gap from edge of screen
00011 #define GAP 2
00012 
00013 class PongEngine
00014 {
00015 
00016 public:
00017     PongEngine();
00018     ~PongEngine();
00019 
00020     void init(int paddle_width,int paddle_height,int ball_size,int speed);
00021     void read_input(Gamepad &pad);
00022     void update(Gamepad &pad);
00023     void draw(N5110 &lcd);
00024     
00025 private:
00026 
00027     void check_wall_collision(Gamepad &pad);
00028     void check_paddle_collisions(Gamepad &pad);
00029     void check_goal(Gamepad &pad);
00030     void print_scores(N5110 &lcd);
00031     
00032     Paddle _p1;
00033     Paddle _p2;
00034      
00035     int _paddle_width;
00036     int _paddle_height;
00037     int _ball_size;
00038     int _speed;
00039     
00040     // x positions of the paddles
00041     int _p1x;
00042     int _p2x;
00043     
00044     Ball _ball;
00045     
00046     Direction _d;
00047     float _mag;
00048 
00049 };
00050 
00051 #endif