Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
My_game_clases/Functions.h
- Committer:
- thestudent
- Date:
- 2020-04-29
- Revision:
- 14:739115711bf8
- Parent:
- 13:1dbef50789ed
- Child:
- 15:3f558f8b54ea
File content as of revision 14:739115711bf8:
#ifndef FUNCTIONS_H
#define FUNCTIONS_H
//includes
#include "mbed.h"
#include "N5110.h"
#include "Gamepad.h"
#include "Objects.h"
struct Ball{
    int ball_x_pos[10]; // balls x position
    float movement_y_counter[10]; //sets the gravity with which the ball will fall
    int time[10];//the time as in the y postion of the ball which will governed by equation y = _y_initial + _movement_y_counter * _time^2
    int ball_y_pos[10];//balls_y_position
    int time_incrementer[10];//increments time value
    int ball_x_incrementer[10];//increments movement_x_pos value
    int delta_r[10]; // defines the ball size    
    int initial_starting_pos[10];
    int time_limit[10];// restrict time to 6 or 5 depending on the balls size
    
};
struct Ball_linear{
    int ball_x_pos[10]; // moves the ball across the screen
    int movement_y_counter[10]; //sets the gravity with which the ball will fall
    int ball_y_pos[10];//balls_y_position
    int time_incrementer[10];//increments time value
    int ball_x_incrementer[10];//increments movement_x_pos value
    int delta_r[10]; // defines the ball size    
    
    
};
class Functions 
{
public:
    Functions();
    void ball_position_parabolic( N5110 &lcd, Objects &objects, int c);//governs the balls movement in a parabolic way
    void ball_position_linear (N5110 &lcd, Objects &objects, int c);//governs the balls movement in a linear way
    void collision_checker(N5110 &lcd,Objects &objects);//checks if the shot has coma into contact with the ball
    void ball1_finder(int x, int y);//checks which ball has been hit by a shot and then decreses it size(linear)
    void ball_finder(int x, int y);//checks which ball has been hit by a shot and then decreses it size(parabolic)
    bool cannon_smash(N5110 &lcd,Objects &objects);// checks if the cannon has crashed with anything
    int random(Gamepad &pad);//generates a random number
    void ball_creater_linear(N5110 &lcd, Objects &objects, Gamepad &pad);//controls ball making and their movement equations
    void ball_creater_parabolic(N5110 &lcd, Objects &objects, Gamepad &pad);//controls ball making and their movement
    int get_score();//gets the players score
    
    vector <int> created_balls;//holds linear balls
    vector <int> created_ball;//holds the parabolic balls
private:
    int _initial_radiuss;//holds the intial ball radiuss which is 2
    int _cannon_y_pos; // holds the cannons y position
    int _score;//holds the score
};
#endif