-
Notifications
You must be signed in to change notification settings - Fork 0
/
gamemode.c
88 lines (75 loc) · 2.14 KB
/
gamemode.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include <stdint.h>
#include <pic32mx.h>
#include "mipslab.h"
#include <stdio.h>
#include <stdlib.h>
//Game specific variables
float game_active = 0;
float game_mode = 0;
int score_player1 = 0;
float score_player2 = 0;
int ai_difficulty = 16; // 4Easy, 2Medium, 1Hard
float player = 0;
int light_counter = 0;
int player_lives = 3;
void one_player(btns) {
player_movement_one(btns);
ai_move();
ball_movement();
paddle_hit();
clearDisplay();
setPixelArray(paddle1_xPos, paddle1_yPos, paddle_width, paddle_height);
setPixelArray(paddle2_xPos, paddle2_yPos, paddle_width, paddle_height);
setPixelArray(ball_xPos, ball_yPos, ball_size, ball_size);
translateToImage();
display_image(0, oled_display);
}
void score_mode(btns) {
player_movement_one(btns);
ai_move();
ball_movement();
paddle_hit();
clearDisplay();
setPixelArray(paddle1_xPos, paddle1_yPos, paddle_width, paddle_height);
setPixelArray(paddle2_xPos, paddle2_yPos, paddle_width, paddle_height);
setPixelArray(ball_xPos, ball_yPos, ball_size, ball_size);
translateToImage();
display_image(0, oled_display);
}
void two_player(btns) {
player_movement_two(btns);
ball_movement();
paddle_hit();
clearDisplay();
/*
if((ball_yPos + ball_size > paddle1_yPos) && (ball_yPos <= paddle1_yPos + 2) && (ball_xPos == paddle_width)){
i = 1;
}
if((ball_yPos > paddle1_yPos + 2) && (ball_yPos <= paddle1_yPos + 4) && (ball_xPos == paddle_width)){
j = 1;
}
if((ball_yPos > paddle1_yPos + 4) && (ball_yPos <= paddle1_yPos + 6) && (ball_xPos == paddle_width)){
k = 1;
}
if((ball_yPos > paddle1_yPos + 6) && (ball_yPos - ball_size < paddle1_yPos + 8) && (ball_xPos == paddle_width)){
m = 1;
}
if(i){
setPixelArray(10, 10, 2, 2);
}
if(j){
setPixelArray(50, 10, 2, 2);
}
if(k){
setPixelArray(90, 10, 2, 2);
}
if(m){
setPixelArray(120, 10, 2, 2);
}
*/
setPixelArray(paddle1_xPos, paddle1_yPos, paddle_width, paddle_height);
setPixelArray(paddle2_xPos, paddle2_yPos, paddle_width, paddle_height);
setPixelArray(ball_xPos, ball_yPos, ball_size, ball_size);
translateToImage();
display_image(0, oled_display);
}