Skip to content
This repository has been archived by the owner on Jun 3, 2023. It is now read-only.

Commit

Permalink
いろいろ修正
Browse files Browse the repository at this point in the history
  • Loading branch information
su8ru committed Oct 9, 2018
1 parent be91b6c commit 7121fd4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
25 changes: 11 additions & 14 deletions SpaceWars2/functions/Player.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
#include "Player.hpp"

#define SPEED 3
#define PLAYER_SPEED 10

void Player::Init(int32 _x, int32 _y, bool _isLeft){
posX = _x;
Expand All @@ -10,23 +10,20 @@ void Player::Init(int32 _x, int32 _y, bool _isLeft){
}

void Player::Control(){
int32 tmpX = 0, tmpY = 0;
Rect tmpZoon;
tmpX = this->posX;
tmpY = this->posY;

if(this->isLeft){
if(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;
if(Input::KeyD.pressed && tmpZoon.contains(Circle(posX + PLAYER_SPEED, posY, 40))) posX += PLAYER_SPEED;
if(Input::KeyA.pressed && tmpZoon.contains(Circle(posX - PLAYER_SPEED, posY, 40))) posX -= PLAYER_SPEED;
if(Input::KeyW.pressed && tmpZoon.contains(Circle(posX, posY - PLAYER_SPEED, 40))) posY -= PLAYER_SPEED;
if(Input::KeyS.pressed && tmpZoon.contains(Circle(posX, posY + PLAYER_SPEED, 40))) posY += PLAYER_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;
if(Input::KeySemicolon.pressed && tmpZoon.contains(Circle(posX + PLAYER_SPEED, posY, 40))) posX += PLAYER_SPEED;
if(Input::KeyK.pressed && tmpZoon.contains(Circle(posX - PLAYER_SPEED, posY, 40))) posX -= PLAYER_SPEED;
if(Input::KeyO.pressed && tmpZoon.contains(Circle(posX, posY - PLAYER_SPEED, 40))) posY -= PLAYER_SPEED;
if(Input::KeyL.pressed && tmpZoon.contains(Circle(posX, posY + PLAYER_SPEED, 40))) posY += PLAYER_SPEED;
}
this->ship = Circle(this->posX, this->posY, 40);
ship = Circle(posX, posY, 40);
}
2 changes: 0 additions & 2 deletions SpaceWars2/scenes/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ void Game::init() {
this->CicaR32 = Font(32, L"Cica"); // :ac:
m_data->count++;
Println(m_data->count);
m_data->LPlayer.Init(40, 540, true);
m_data->RPlayer.Init(1880, 540, false);
}

void Game::update() {
Expand Down
2 changes: 2 additions & 0 deletions SpaceWars2/scenes/Opening.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ void Opening::init(){
this->CicaR32 = Font(32, L"Cica"); // :ac:
m_data->count++;
Println(m_data->count);
m_data->LPlayer.Init(40, 540, true);
m_data->RPlayer.Init(1880, 540, false);
}

void Opening::update(){
Expand Down

0 comments on commit 7121fd4

Please sign in to comment.