Skip to content

Commit f71773d

Browse files
author
tigertang
committed
Merge from master
2 parents 479ee83 + d201629 commit f71773d

File tree

23 files changed

+412
-92
lines changed

23 files changed

+412
-92
lines changed
Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
11
#pragma once
22

3+
#include <memory>
4+
35
#include "bullet_common.h"
46
#include "object.h"
7+
#include "color.h"
8+
#include "timer.h"
59

610
class World;
711

812
class Character {
913
protected:
1014
static float static_pace_;
11-
float max_speed_;
12-
Object* object_;
1315
World* world_;
16+
Object* object_;
17+
// Config
18+
float max_speed_ = 15;
19+
float laser_attack_freq_ = 1;
20+
float laser_attack_dist_ = 10;
21+
Color laser_attack_color_ = color::Blue();
22+
float box_attack_freq_ = 3;
23+
float box_attack_dist_ = 5;
24+
float box_attack_range_ = 5; // along depth axis
25+
Color box_attack_color_ = color::Red();
1426
public:
15-
Character(World*, Object*, float speed = 15);
27+
Character(World*, Object*);
1628
~Character();
1729
void Bind(Object* object);
1830
Object* GetDelegate(void);
@@ -23,4 +35,6 @@ class Character {
2335
void ResetRotate(void);
2436
void LaserAttack(void);
2537
void BoxAttack(void);
26-
};
38+
void Gain(float);
39+
void Lose(float);
40+
};

include/happy_bird/particle.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ enum ParticleFlag{
6666
kRandomColorParticle = 0x60, // 00 for mono
6767
// origin var
6868
kJitterParticle = 0x80,
69-
// inner force
70-
kInnerParticle = 0x100
69+
// Special effect
70+
kMockFlame = 0x100
7171
} ;
7272
struct ParticleConfig{
7373
// explicit assigned
@@ -88,7 +88,7 @@ struct ParticleConfig{
8888
bool gradual; // true for gradual change
8989
// external option
9090
bool jitter;
91-
bool inner_force;
91+
bool mock_flame;
9292

9393
ParticleConfig(glm::vec3 v, Color color, int flags = 0);
9494
};

include/happy_bird/stage.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ class Stage{
1919
friend Stage;
2020
std::shared_ptr<Object> data_ref_;
2121
public:
22+
StageWrapper(std::shared_ptr<Object> shared): data_ref_(shared){ }
2223
StageWrapper(Object* naked): data_ref_(naked){ }
24+
~StageWrapper(){ }
2325
std::weak_ptr<Object> get(void){
2426
return static_cast<std::weak_ptr<Object> >(data_ref_);
2527
}

include/happy_bird/temp_collection.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22

3+
#include <iostream>
34
#include <list>
45
#include <memory>
56

@@ -16,6 +17,10 @@ class TempCollection{
1617
TempWrapper(Object* naked, float duration):data_ref_(naked), duration_(duration){
1718
timer_ = Timer::New();
1819
}
20+
TempWrapper(std::shared_ptr<Object> shared, float duration):data_ref_(shared), duration_(duration){
21+
timer_ = Timer::New();
22+
}
23+
~TempWrapper(){ }
1924
std::weak_ptr<Object> get(void){
2025
return static_cast<std::weak_ptr<Object> >(data_ref_);
2126
}
@@ -33,6 +38,7 @@ class TempCollection{
3338
}
3439
void Update(void);
3540
void PushBack(Object* object, float duration); // second
41+
void PushBack(std::shared_ptr<Object> object, float duration);
3642
private:
3743
World* world_;
3844
ObjectContainer objects_;

include/happy_bird/world.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class World{
4444
TempCollection temp_;
4545
public:
4646
// shared
47+
static bool exit;
4748
static int height, width;
4849
static Camera* camera;
4950
static glm::vec3 global_ambient;

resources/hero.png

142 KB
Loading

resources/hero_0.png

1008 Bytes
Loading

resources/vampire.png

143 KB
Loading

shader/blood_decr.frag

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#version 330 core
2+
3+
uniform vec3 uColor;
4+
5+
in vec3 vColor;
6+
out vec4 FragColor;
7+
8+
void main(){
9+
// Halo shading //
10+
vec2 radiant = gl_PointCoord - vec2(0.5, 0.5);
11+
float radiusSquare = dot(radiant, radiant);
12+
if(abs(radiant.y) < 0.1 && abs(radiant.x) < 0.2){
13+
FragColor = vec4(vColor, 1.0);
14+
}
15+
else if(radiusSquare < 0.15){ // from 0.0625 to 0.25
16+
FragColor = vec4(vColor, 0.15 - radiusSquare);
17+
}
18+
else{
19+
discard;
20+
}
21+
// FragColor = vec4(vColor, 1.0);
22+
}

shader/blood_incr.frag

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@
22

33
uniform vec3 uColor;
44

5+
in vec3 vColor;
56
out vec4 FragColor;
67

78
void main(){
89
// Halo shading //
910
vec2 radiant = gl_PointCoord - vec2(0.5, 0.5);
1011
float radiusSquare = dot(radiant, radiant);
1112
if(abs(radiant.x) < 0.07 && abs(radiant.y) < 0.2 || abs(radiant.y) < 0.07 && abs(radiant.x) < 0.2){
12-
FragColor = vec4(uColor, 1.0);
13+
FragColor = vec4(vColor, 1.0);
1314
}
1415
else if(radiusSquare < 0.25){ // from 0.0625 to 0.25
15-
FragColor = vec4(uColor, 0.25 - radiusSquare);
16+
FragColor = vec4(vColor, 0.25 - radiusSquare);
1617
}
1718
else{
1819
discard;
1920
}
20-
// FragColor = vec4(uColor, 1.0);
21+
// FragColor = vec4(vColor, 1.0);
2122
}

0 commit comments

Comments
 (0)