-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCharacter.cpp
More file actions
54 lines (47 loc) · 1.13 KB
/
Character.cpp
File metadata and controls
54 lines (47 loc) · 1.13 KB
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
#include <GLFW/glfw3.h>
#include <cmath>
#include <iostream>
#include "Character.h"
#include "ShapeDrawer.h"
Character::Character(int texture){
this->frame = 0;
this->texture = texture;
}
void Character::updateFrame(float deltaT){
float frameSpeed = 10.0;
this->frame += frameSpeed*deltaT;
if(this->frame > 2*M_PI){
this->frame -= 2*M_PI;
}
}
void Character::draw(){
glPushMatrix();
glTranslatef(0, -3, -10);
glScaled(0.5,0.5,0.5);
// glRotatef(90, 0, 1, 0);
glPushMatrix();
glTranslatef(0, 1, 0);
ShapeDrawer::cube(this->texture);
glPopMatrix();
glPushMatrix();
glScaled(0.4,0.4,0.4);
glTranslatef(-1.5, 0, 0);
ShapeDrawer::cube(this->texture);
glTranslatef(3, 0, 0);
ShapeDrawer::cube(this->texture);
glPopMatrix();
glPushMatrix();
glRotatef(sin(frame)*45, 1, 0, 0);
glTranslatef(1,-1,0);
glScaled(0.5,0.5,0.5);
ShapeDrawer::cube(this->texture);
glPopMatrix();
glPushMatrix();
glRotatef(-sin(frame)*45, 1, 0, 0);
glTranslatef(-1,-1,0);
glScaled(0.5,0.5,0.5);
ShapeDrawer::cube(this->texture);
glPopMatrix();
glPopMatrix();
glTranslatef(0, 0, -10);
}