0
已解决
王祥羽
修练者
修练者
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#include<fstream>
#include<windows.h>
#ifndef _WINDOWS_
#define _WINDOWS_
#include <_mingw.h>
#include <sdkddkver.h>
#ifdef __OBJC__
#pragma push_macro("interface")
#undef interface
#define interface struct
#endif
#ifndef _INC_WINDOWS
#define _INC_WINDOWS
#if defined(RC_INVOKED) && !defined(NOWINRES)
#include <winresrc.h>
#else
#ifdef RC_INVOKED
#define NOATOM
#define NOGDI
#define NOGDICAPMASKS
#define NOMETAFILE
#define NOMINMAX
#define NOMSG
#define NOOPENFILE
#define NORASTEROPS
#define NOSCROLL
#define NOSOUND
#define NOSYSMETRICS
#define NOTEXTMETRIC
#define NOWH
#define NOCOMM
#define NOKANJI
#define NOCRYPT
#define NOMCX
#endif
#if defined(__x86_64) && \
!(defined(_X86_) || defined(__i386__) || defined(_IA64_))
#if !defined(_AMD64_)
#define _AMD64_
#endif
#endif
#if defined(__ia64__) && \
!(defined(_X86_) || defined(__x86_64) || defined(_AMD64_))
#if !defined(_IA64_)
#define _IA64_
#endif
#endif
#ifndef RC_INVOKED
#include <excpt.h>
#include <stdarg.h>
#endif
#include <windef.h>
#include <winbase.h>
#include <wingdi.h>
#include <winuser.h>
#include <winnls.h>
#include <wincon.h>
#include <winver.h>
#include <winreg.h>
#include <winnetwk.h>
#include <virtdisk.h>
#ifndef WIN32_LEAN_AND_MEAN
#include <cderr.h>
#include <dde.h>
#include <ddeml.h>
#include <dlgs.h>
#include <lzexpand.h>
#include <mmsystem.h>
#include <nb30.h>
#include <rpc.h>
#include <shellapi.h>
#include <winperf.h>
#if defined(__USE_W32_SOCKETS) || !defined(__CYGWIN__)
#include <winsock.h>
#endif
#ifndef NOCRYPT
#include <wincrypt.h>
#include <winefs.h>
#include <winscard.h>
#endif
#ifndef NOUSER
#ifndef NOGDI
#include <winspool.h>
#ifdef INC_OLE1
#include <ole.h>
#else
#include <ole2.h>
#endif
#include <commdlg.h>
#endif
#endif
#endif
#ifndef __CYGWIN__
#include <stralign.h>
#endif
#ifdef INC_OLE2
#include <ole2.h>
#endif
#ifndef NOSERVICE
#include <winsvc.h>
#endif
#ifndef NOMCX
#include <mcx.h>
#endif
#ifndef NOIME
#include <imm.h>
#endif
#endif
#endif
#ifdef __OBJC__
#pragma pop_macro("interface")
#endif
#endif
#include<conio.h>
#include<iomanip>
#define large 4557430888798830399
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
#define height 21
#define sl 15
using namespace std;
long double xs,ys,ysp=0,xsp=0,cnt=0,xe=0.0001;
int x=2,y=1;
string mp[]={
"###########################################################",
"## ##",
"## ##",
"## >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ##",
"## ###################################### ##",
"## ## ## ## ##",
"## ## ## ## ##",
"## ## ## << ## ##",
"## ## ## ## ## ##",
"## ## ## ** ## ##",
"## ## ## ## ## ##",
"## ## ## ## ## ##",
"## ## ## ## ## ##",
"## ## ## ## ## ##",
"## ## ## }} ## ##",
"## ##### ## ## }} << ##",
"## << ## ## ## ++<<## ##",
"## ## << ## ## ## ##",
"## ## ## ## ##^^ ##",
"## ## ## ## ##",
"##>>>>>>++##^^<<<<<<<<<<<<<<<##++<<<<<<<<<<<<<<##>>>>^^{{##",
"###########################################################"
};
void SetPos(COORD a) {
HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(out, a);
}
void SetPos(int i, int j) {
COORD pos = { i, j };
SetPos(pos);
}
void color(int a) {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), a);
}
void Hide_Pos(void) {
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO cci;
GetConsoleCursorInfo(hOut, &cci);
cci.bVisible = FALSE;
SetConsoleCursorInfo(hOut, &cci);
}
void Show_Pos(void) {
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO cci;
GetConsoleCursorInfo(hOut, &cci);
cci.bVisible = TRUE;
SetConsoleCursorInfo(hOut, &cci);
}
void Move_CheckCrash(){
if(ysp>=0){
for(double yyy=xe;yyy<=ysp-xe;yyy+=xe){
ys+=xe;
if(mp[height-1-int(ceil(ys))][x]!=' '&&mp[20-int(ceil(ys))][x]!='~'){
ys+=(0-yyy),ysp=(0-ysp)*0.75;
xsp*=0.75;
break;
}
}
}else{
for(double yyy=-xe;yyy>=ysp+xe;yyy-=xe){
ys-=xe;
if(mp[height-1-int(ceil(ys))][x]!=' '&&mp[20-int(ceil(ys))][x]!='~'){
ys+=(0-yyy),ysp=(0-ysp)*0.75;
xsp*=0.75;
break;
}
}
}
y=ceil(ys);
if(xsp>=0){
for(double xxx=xe;xxx<=xsp-xe;xxx+=xe){
xs+=xe;
if(mp[height-1-y][int(ceil(xs))]!=' '&&mp[20-y][int(ceil(xs))]!='~'){
xs+=(0-xxx),xsp=(0-xsp)*0.75;
ysp*=0.75;
break;
}
}
}else{
for(double xxx=-xe;xxx>=xsp+xe;xxx-=xe){
xs-=xe;
if(mp[height-1-y][int(ceil(xs))]!=' '&&mp[20-y][int(ceil(xs))]!='~'){
xs+=(0-xxx),xsp=(0-xsp)*0.75;
ysp*=0.75;
break;
}
}
}
x=ceil(xs);
return;
}
void CheckBlockType(double yiz){
if(mp[height-1-y][x]=='~'){
ysp+=yiz*2;
xsp*=(1-xe);
}
if(mp[height-2-y][x]=='<'||mp[height-y][x]=='<'||mp[height-1-y][x+1]=='<'){
xsp-=2;
if(xsp<-2){
xsp=-2;
}
}
if(mp[height-2-y][x]=='>'||mp[height-y][x]=='>'||mp[height-1-y][x-1]=='<'){
xsp+=2;
if(xsp>2){
xsp=2;
}
}
if(mp[height-y][x]=='^'||mp[height-1-y][x+1]=='^'||mp[height-1-y][x]=='^'){
ysp+=2;
if(ysp>2){
ysp=2;
}
}
if(mp[height-2-y][x]=='{'||mp[height-y][x]=='{'||mp[height-1-y][x+1]=='{'){
xsp-=4;
if(xsp<-4){
xsp=-4;
}
}
if(mp[height-2-y][x]=='}'||mp[height-y][x]=='}'||mp[height-1-y][x-1]=='}'){
xsp+=4;
if(xsp>4){
xsp=4;
}
}
if(mp[height-y][x]=='+'||mp[height-1-y][x+1]=='+'||mp[height-1-y][x]=='+'){
ysp+=4;
if(ysp>4){
ysp=4;
}
}
if(mp[height-y][x]=='*'||mp[height-1-y][x+1]=='*'||mp[height-1-y][x]=='*'||mp[height-1-y][x-1]=='*'){
if(ysp>0){
ysp-=2;
if(ysp<0){
ysp=0;
}
}else if(ysp<0){
ysp+=2;
if(ysp>0){
ysp=0;
}
}
if(xsp>0){
xsp-=2;
if(xsp<0){
xsp=0;
}
}else if(xsp<0){
xsp+=2;
if(xsp>0){
xsp=0;
}
}
}
return;
}
void move(double yiz=0.15){
ysp-=yiz;
Move_CheckCrash();
cout<<" ";
SetPos(0,22);
cout<<x<<" "<<y<<" "<<xs<<" "<<ys<<" "<<xsp<<" "<<ysp;
CheckBlockType(yiz);
return;
}
void print(){
SetPos(0,0);
for(int i=0;i<=21;i++){
for(int j=0;j<=58;j++){
if(mp[i][j]=='#'){
color(255);
cout<<" ";
color(15);
}else if(mp[i][j]==' '){
cout<<" ";
}else if(mp[i][j]=='>'){
color(160);
cout<<">";
color(15);
}else if(mp[i][j]=='<'){
color(160);
cout<<"<";
color(15);
}else if(mp[i][j]=='^'){
color(160);
cout<<"^";
color(15);
}else if(mp[i][j]=='}'){
color(64);
cout<<">";
color(15);
}else if(mp[i][j]=='{'){
color(64);
cout<<"<";
color(15);
}else if(mp[i][j]=='+'){
color(64);
cout<<"^";
color(15);
}else if(mp[i][j]=='~'){
color(27);
cout<<"~";
color(15);
}else if(mp[i][j]=='*'){
color(110);
cout<<"*";
color(15);
}
}
cout<<endl;
}
return;
}
bool printb(){
SetPos(x,(20-y));
if(mp[height-1-y][x]=='~'){
color(31);
}
cout<<"o";
color(15);
}
int main(void) {
color(15);
xs=x,ys=y;
ys+=ysp;
Hide_Pos();
while(1){
print();
move();
printb();
Sleep(sl);
}
return 0;
}
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0