This repository has been archived by the owner on Aug 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
下一次更新考虑实现多线程播放音乐,防止播放音乐时引起卡顿。
- Loading branch information
Wider
committed
May 3, 2020
1 parent
b8d0ee2
commit 2200177
Showing
31 changed files
with
473 additions
and
281 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "Bullet.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#pragma once | ||
#include "BaseObject.h" | ||
class Bullet: | ||
public BaseObject | ||
{ | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include "Controller.h" | ||
|
||
void Controller::play_music(string type) | ||
{ | ||
if(type == "welcome") { | ||
mciSendString(_T("close all"), NULL, 0, NULL);//界岺杰唐稜있 | ||
mciSendString(_T("open \"assets\\audios\\bg.mp3\" alias welcome"), NULL, 0, NULL);//뻑短稜있 | ||
mciSendString(_T("play welcome repeat"), NULL, 0, NULL);//琦뻔꺄렴 | ||
} | ||
else if(type == "gaming") { | ||
mciSendString(_T("close all"), NULL, 0, NULL);//界岺杰唐稜있 | ||
mciSendString(_T("open \"assets\\audios\\bg.mp3\" alias gaming"), NULL, 0, NULL);//교쒼稜있 | ||
mciSendString(_T("play gaming"), NULL, 0, NULL);//琦뻔꺄렴 | ||
} | ||
else if(type == "accele") { | ||
mciSendString(_T("stop gaming"), NULL, 0, NULL);//界岺杰唐稜있 | ||
mciSendString(_T("open \"assets\\audios\\bg_accele.mp3\" alias accele"), NULL, 0, NULL);//교쒼稜있속醵 | ||
mciSendString(_T("play accele"), NULL, 0, NULL);//琦뻔꺄렴 | ||
} | ||
else if(type == "jump") { | ||
mciSendString(_T("close jump"), NULL, 0, NULL); | ||
mciSendString(_T("open \"assets\\audios\\jump.mp3\" alias jump"), NULL, 0, NULL);//契禿稜있 | ||
mciSendString(_T("play jump"), NULL, 0, NULL);//琦뻔꺄렴 | ||
} | ||
else if(type == "win") { | ||
mciSendString(_T("close all"), NULL, 0, NULL);//界岺杰唐稜있 | ||
mciSendString(_T("open \"assets\\audios\\win.mp3\" alias win"), NULL, 0, NULL);//價적稜있 | ||
mciSendString(_T("play win"), NULL, 0, NULL);//琦뻔꺄렴 | ||
} | ||
else if(type == "mario death") { | ||
mciSendString(_T("close all"), NULL, 0, NULL);//界岺杰唐稜있 | ||
mciSendString(_T("open \"assets\\audios\\mario_death.mp3\" alias mario_death"), NULL, 0, NULL);//呵겨稜있 | ||
mciSendString(_T("play mario_death"), NULL, 0, NULL);//琦뻔꺄렴 | ||
} | ||
else if(type == "enemy death") { | ||
mciSendString(_T("close enemy_death"), NULL, 0, NULL); | ||
mciSendString(_T("open \"assets\\audios\\enemy_death.mp3\" alias enemy_death"), NULL, 0, NULL);//柰밍价空稜있 | ||
mciSendString(_T("play enemy_death"), NULL, 0, NULL);//琦뻔꺄렴 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
|
||
#ifndef _CONTROLLER_H_ | ||
#define _CONTROLLER_H_ | ||
#include "Global.h" | ||
#include <mmsystem.h> | ||
#pragma comment(lib,"Winmm.lib") | ||
#include <windows.h> | ||
|
||
class Controller | ||
{ | ||
private: | ||
|
||
public: | ||
void welcome(); | ||
void win(); | ||
void lose(); | ||
void play_music(string type); | ||
void show_welcome_ui(); | ||
void show_gaming_ui(); | ||
void show_lose_ui(); | ||
void show_help_ui(); | ||
}; | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#include "Enemy.h" | ||
|
||
void Enemy::init() | ||
{ | ||
LPCTSTR img_src, mask_src; | ||
img_src = _T("assets\\images\\enemy.png"); | ||
mask_src = _T("assets\\images\\enemy_mask.png"); | ||
int figure_num = 4; | ||
IMAGE origin, organ_mask; | ||
loadimage(&origin, img_src); | ||
loadimage(&organ_mask, mask_src); | ||
int width = origin.getwidth() / figure_num; | ||
int height = origin.getheight(); | ||
this->width(width); | ||
this->height(height); | ||
vector<IMAGE> imgs, masks; | ||
IMAGE temp; | ||
|
||
imgs.clear(); masks.clear(); | ||
for(int i = 0; i < 2; i++) { | ||
SetWorkingImage(&origin); | ||
getimage(&temp, 0 + width * i, 0, width, height); | ||
imgs.push_back(temp); | ||
SetWorkingImage(&organ_mask); | ||
getimage(&temp, 0 + width * i, 0, width, height); | ||
masks.push_back(temp); | ||
} | ||
figure.addFigure("running", imgs, masks, [this]()->bool { | ||
if(!is_killed()) return true; | ||
return false; | ||
}); | ||
|
||
|
||
|
||
imgs.clear(); masks.clear(); | ||
for(int i = 2; i < 4; i++) { | ||
SetWorkingImage(&origin); | ||
getimage(&temp, 0 + width * i, 0, width, height); | ||
imgs.push_back(temp); | ||
SetWorkingImage(&organ_mask); | ||
getimage(&temp, 0 + width * i, 0, width, height); | ||
masks.push_back(temp); | ||
} | ||
figure.addFigure("killed", imgs, masks, [this]()->bool { | ||
if(is_killed()) return true; | ||
return false; | ||
}); | ||
SetWorkingImage(NULL); | ||
|
||
} | ||
|
||
void Enemy::kill() | ||
{ | ||
BaseObject::kill(); | ||
kill_tick = steady_clock::now(); | ||
} | ||
|
||
|
||
|
||
void Enemy::move_range(double a, double b) | ||
{ | ||
range_left = a; | ||
range_right = b; | ||
} | ||
|
||
double Enemy::move_range_left() | ||
{ | ||
return range_left; | ||
} | ||
|
||
double Enemy::move_range_right() | ||
{ | ||
return range_right; | ||
} | ||
|
||
bool Enemy::is_removed() | ||
{ | ||
if(is_killed()&&duration<double, std::milli>(steady_clock::now() - kill_tick).count() > 750) | ||
return true; | ||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
#include "BaseObject.h" | ||
class Enemy: public BaseObject | ||
{ | ||
private: | ||
double range_left, range_right; | ||
time_point<steady_clock> kill_tick; | ||
public: | ||
Enemy():BaseObject(unit_length * 4, unit_length * 11),range_left(0),range_right(0){} | ||
Enemy(const double x, const double y,const double range_left,const double range_right): | ||
BaseObject(x,y),range_left(range_left),range_right(range_right){} | ||
void init(); | ||
void kill(); | ||
void move_range(double a, double b); | ||
double move_range_left(); | ||
double move_range_right(); | ||
bool is_removed(); | ||
|
||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.