From 1cea62c7ae836e1c8048cbac7c59980c708fb4f8 Mon Sep 17 00:00:00 2001 From: subaru2003 Date: Sun, 7 Oct 2018 22:57:23 +0900 Subject: [PATCH 1/4] =?UTF-8?q?Player=E3=81=AE=E5=9F=BA=E6=9C=AC=E7=9A=84?= =?UTF-8?q?=E3=81=AA=E7=A7=BB=E5=8B=95=E3=83=BB=E5=BD=93=E3=81=9F=E3=82=8A?= =?UTF-8?q?=E5=88=A4=E5=AE=9A=E3=82=92=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SpaceWars2/CommonData.hpp | 4 ++++ SpaceWars2/config.hpp | 4 ++-- SpaceWars2/functions/Player.cpp | 36 ++++++++++++++++++++++++++++++++- SpaceWars2/functions/Player.hpp | 13 +++++++++++- SpaceWars2/scenes/Game.cpp | 14 +++++++------ 5 files changed, 61 insertions(+), 10 deletions(-) diff --git a/SpaceWars2/CommonData.hpp b/SpaceWars2/CommonData.hpp index a277d20..82254aa 100644 --- a/SpaceWars2/CommonData.hpp +++ b/SpaceWars2/CommonData.hpp @@ -2,7 +2,11 @@ #include #include "Config.hpp" +#include "./functions/Player.hpp" + typedef struct { int count = 0; Texture background = Texture(L"images/background.png"); + Player LPlayer; + Player RPlayer; } CommonData; diff --git a/SpaceWars2/config.hpp b/SpaceWars2/config.hpp index 784e38d..fa47757 100644 --- a/SpaceWars2/config.hpp +++ b/SpaceWars2/config.hpp @@ -7,8 +7,8 @@ namespace Config { const String Title = L"SPACE WARS 2"; // サイズ - const int32 Width = 1920; - const int32 Height = 1080; + const int32 Width = 1280; + const int32 Height = 720; // 背景色 const String Background = L"#ffffff"; diff --git a/SpaceWars2/functions/Player.cpp b/SpaceWars2/functions/Player.cpp index 7b9637e..a6ada18 100644 --- a/SpaceWars2/functions/Player.cpp +++ b/SpaceWars2/functions/Player.cpp @@ -1 +1,35 @@ -#pragma once \ No newline at end of file +#pragma once +#include "Player.hpp" + +#define SPEED 3 + +void Player::Init(int32 _x, int32 _y, bool _isLeft){ + posX = _x; + posY = _y; + isLeft = _isLeft; +} + +void Player::Control(){ + int32 tmpX = 0, tmpY = 0; + Rect tmpZoon;// = Rect(0, 0, 0, 0); + tmpX = this->posX; + tmpY = this->posY; + if(this->isLeft){ + if(Input::KeyD.pressed) this->posX += SPEED; + else if(Input::KeyA.pressed) this->posX -= SPEED; + if(Input::KeyW.pressed) this->posY -= SPEED; + else if(Input::KeyS.pressed) this->posY += SPEED; + tmpZoon = Rect(0, 0, Config::Width / 2, Config::Height); + }else{ + if(Input::KeySemicolon.pressed) this->posX += SPEED; + else if(Input::KeyK.pressed) this->posX -= SPEED; + if(Input::KeyO.pressed) this->posY -= SPEED; + else if(Input::KeyL.pressed) this->posY += SPEED; + tmpZoon = Rect(Config::Width/2, 0, Config::Width / 2, Config::Height); + } + this->ship = Circle(this->posX, this->posY, 40); + if(tmpZoon.contains(this->ship) == false){ + this->posX = tmpX; + this->posY = tmpY; + } +} \ No newline at end of file diff --git a/SpaceWars2/functions/Player.hpp b/SpaceWars2/functions/Player.hpp index bbdb23b..4e90d4c 100644 --- a/SpaceWars2/functions/Player.hpp +++ b/SpaceWars2/functions/Player.hpp @@ -1,3 +1,14 @@ #pragma once #include -#include "../Config.hpp" \ No newline at end of file +#include "../Config.hpp" + +class Player { + public: + int32 posX; + int32 posY; + bool isLeft; + Circle ship; + + void Init(int32, int32, bool); + void Control(); +}; diff --git a/SpaceWars2/scenes/Game.cpp b/SpaceWars2/scenes/Game.cpp index 4252642..d44d35d 100644 --- a/SpaceWars2/scenes/Game.cpp +++ b/SpaceWars2/scenes/Game.cpp @@ -2,24 +2,26 @@ #include "Game.hpp" #include "../Config.hpp" +#include "../functions/Player.hpp" + void Game::init() { this->CicaR32 = Font(32, L"Cica"); // :ac: m_data->count++; Println(m_data->count); + m_data->LPlayer.Init(40, 360, true); + m_data->RPlayer.Init(1240, 360, false); } void Game::update() { if (Input::KeyEnter.clicked) changeScene(L"Finish"); - if (this->mode) - y++; - else - y--; - if (y < 0)mode = true; - if (y > 800)mode = false; + m_data->LPlayer.Control(); + m_data->RPlayer.Control(); } void Game::draw() const { m_data->background.resize(Config::Width, Config::Height).draw(); CicaR32(L"I am game scene! Hello!").drawCenter(y/*200*/, Color(L"#ffffff")); + m_data->LPlayer.ship.draw(Color(L"#ff0000")); + m_data->RPlayer.ship.draw(Color(L"#0000ff")); } From 74fc378c648a24ef4db51909f4c9d8404fb79af3 Mon Sep 17 00:00:00 2001 From: subaru2003 Date: Mon, 8 Oct 2018 13:59:47 +0900 Subject: [PATCH 2/4] =?UTF-8?q?=E6=96=9C=E3=82=81=E3=81=AB=E5=8B=95?= =?UTF-8?q?=E3=81=84=E3=81=9F=E3=81=A8=E3=81=8D=E3=81=AE=E6=8C=99=E5=8B=95?= =?UTF-8?q?=EF=BD=A5=E6=9E=A0=E3=81=B8=E3=81=AE=E9=A3=9F=E3=81=84=E8=BE=BC?= =?UTF-8?q?=E3=81=BF=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SpaceWars2/functions/Player.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/SpaceWars2/functions/Player.cpp b/SpaceWars2/functions/Player.cpp index a6ada18..e66f926 100644 --- a/SpaceWars2/functions/Player.cpp +++ b/SpaceWars2/functions/Player.cpp @@ -14,7 +14,22 @@ void Player::Control(){ Rect tmpZoon;// = Rect(0, 0, 0, 0); tmpX = this->posX; tmpY = this->posY; + if(this->isLeft){ + tmpZoon = Rect(0, 0, Config::Width / 2, Config::Height); + if(Input::KeyD.pressed && tmpZoon.contains(Circle(this->posX + SPEED, this->posY, 40))) this->posX += SPEED; + if(Input::KeyA.pressed && tmpZoon.contains(Circle(this->posX - SPEED, this->posY, 40))) this->posX -= SPEED; + if(Input::KeyW.pressed && tmpZoon.contains(Circle(this->posX, this->posY - SPEED, 40))) this->posY -= SPEED; + if(Input::KeyS.pressed && tmpZoon.contains(Circle(this->posX, this->posY + SPEED, 40))) this->posY += SPEED; + }else{ + tmpZoon = Rect(Config::Width/2, 0, Config::Width / 2, Config::Height); + if(Input::KeySemicolon.pressed && tmpZoon.contains(Circle(this->posX + SPEED, this->posY, 40))) this->posX += SPEED; + if(Input::KeyK.pressed && tmpZoon.contains(Circle(this->posX - SPEED, this->posY, 40))) this->posX -= SPEED; + if(Input::KeyO.pressed && tmpZoon.contains(Circle(this->posX, this->posY - SPEED, 40))) this->posY -= SPEED; + if(Input::KeyL.pressed && tmpZoon.contains(Circle(this->posX, this->posY + SPEED, 40))) this->posY += SPEED; + } + this->ship = Circle(this->posX, this->posY, 40); + /*if(this->isLeft){ if(Input::KeyD.pressed) this->posX += SPEED; else if(Input::KeyA.pressed) this->posX -= SPEED; if(Input::KeyW.pressed) this->posY -= SPEED; @@ -31,5 +46,5 @@ void Player::Control(){ if(tmpZoon.contains(this->ship) == false){ this->posX = tmpX; this->posY = tmpY; - } + }*/ } \ No newline at end of file From 5b0aaf06df1bc52382a980a03653833be51db49f Mon Sep 17 00:00:00 2001 From: subaru2003 Date: Mon, 8 Oct 2018 16:07:16 +0900 Subject: [PATCH 3/4] =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E3=82=A2=E3=82=A6=E3=83=88=E6=B6=88=E3=81=97=E5=BF=98=E3=82=8C?= =?UTF-8?q?=E3=81=A6=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SpaceWars2/functions/Player.cpp | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/SpaceWars2/functions/Player.cpp b/SpaceWars2/functions/Player.cpp index e66f926..bd53492 100644 --- a/SpaceWars2/functions/Player.cpp +++ b/SpaceWars2/functions/Player.cpp @@ -11,7 +11,7 @@ void Player::Init(int32 _x, int32 _y, bool _isLeft){ void Player::Control(){ int32 tmpX = 0, tmpY = 0; - Rect tmpZoon;// = Rect(0, 0, 0, 0); + Rect tmpZoon; tmpX = this->posX; tmpY = this->posY; @@ -29,22 +29,4 @@ void Player::Control(){ if(Input::KeyL.pressed && tmpZoon.contains(Circle(this->posX, this->posY + SPEED, 40))) this->posY += SPEED; } this->ship = Circle(this->posX, this->posY, 40); - /*if(this->isLeft){ - if(Input::KeyD.pressed) this->posX += SPEED; - else if(Input::KeyA.pressed) this->posX -= SPEED; - if(Input::KeyW.pressed) this->posY -= SPEED; - else if(Input::KeyS.pressed) this->posY += SPEED; - tmpZoon = Rect(0, 0, Config::Width / 2, Config::Height); - }else{ - if(Input::KeySemicolon.pressed) this->posX += SPEED; - else if(Input::KeyK.pressed) this->posX -= SPEED; - if(Input::KeyO.pressed) this->posY -= SPEED; - else if(Input::KeyL.pressed) this->posY += SPEED; - tmpZoon = Rect(Config::Width/2, 0, Config::Width / 2, Config::Height); - } - this->ship = Circle(this->posX, this->posY, 40); - if(tmpZoon.contains(this->ship) == false){ - this->posX = tmpX; - this->posY = tmpY; - }*/ } \ No newline at end of file From be91b6cbc4723061d8db0e1988b6ccbdb51f8e20 Mon Sep 17 00:00:00 2001 From: subaru2003 Date: Mon, 8 Oct 2018 16:27:54 +0900 Subject: [PATCH 4/4] =?UTF-8?q?=E7=94=BB=E9=9D=A2=E3=82=B5=E3=82=A4?= =?UTF-8?q?=E3=82=BA=E5=A4=89=E3=81=88=E3=81=A1=E3=82=83=E3=81=A3=E3=81=A6?= =?UTF-8?q?=E3=81=9F=E3=81=AE=E3=81=A7=E6=88=BB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SpaceWars2/config.hpp | 4 ++-- SpaceWars2/scenes/Game.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/SpaceWars2/config.hpp b/SpaceWars2/config.hpp index fa47757..784e38d 100644 --- a/SpaceWars2/config.hpp +++ b/SpaceWars2/config.hpp @@ -7,8 +7,8 @@ namespace Config { const String Title = L"SPACE WARS 2"; // サイズ - const int32 Width = 1280; - const int32 Height = 720; + const int32 Width = 1920; + const int32 Height = 1080; // 背景色 const String Background = L"#ffffff"; diff --git a/SpaceWars2/scenes/Game.cpp b/SpaceWars2/scenes/Game.cpp index d44d35d..dde3193 100644 --- a/SpaceWars2/scenes/Game.cpp +++ b/SpaceWars2/scenes/Game.cpp @@ -8,8 +8,8 @@ void Game::init() { this->CicaR32 = Font(32, L"Cica"); // :ac: m_data->count++; Println(m_data->count); - m_data->LPlayer.Init(40, 360, true); - m_data->RPlayer.Init(1240, 360, false); + m_data->LPlayer.Init(40, 540, true); + m_data->RPlayer.Init(1880, 540, false); } void Game::update() {