python – How to implement a simple chat option for a server-client game

Thank you for contributing an answer to Game Development Stack Exchange!

  • Please make sure to respond to the question. Provide details and share your research!

But to avoid

  • Ask for help, clarification, or answer other answers.
  • Make statements based on the opinion; save them with references or personal experience.

Use MathJax to format equations. MathJax reference.

To learn more, read our tips for writing good answers.

Robot Game in C ++ – Code Review Stack Exchange

I have a very basic "game" where a robot is placed on a small 5×5 board and commands are given to it. To begin, the robot must be placed on the board, you can then ask him to move or to rotate left and right. I've tried using object-oriented concepts, but that was not an obligation for my task. I think I did a good job and I would like to know what I did wrong.

Here are some "requirements" that have been given:

  1. The "place" command takes an x, y position and a direction or NORTH, EAST, SOUTH or WEST.
  2. No other command can be executed unless the robot has been placed
  3. Move will advance the robot 1 in the direction in which it is located.
    focused towards.
  4. LEFT and RIGHT will rotate the robot in their respective directions
  5. REPORT will print the current position and direction of travel of the
    robot
  6. Place is a valid order even after it has already been placed
  7. The inputs that will make the robot fall off the board must be
    rejected or ignored
  8. Invalid or "junk" entry must be ignored
  9. The robot will take orders in clear text, the robot must take this
    text and execute the respective instructions as they are valid

Example of entry / exit:

PLACE 1,3, WEST
MOVE
REPORT
Output: 0.3, WEST

and here is my robot.cpp

#include "robot.h"
#include "tabletop.h"
#include "helpers.h"

ToyRobot namespace
{
// used as an interface to provide instructions in text form, the robot will perform
bool Robot :: command (std :: string statement)
{
std :: istringstream iss (statement);
std :: vector tokens {std :: istream_iterator{iss}, std :: istream_iterator{}};

if (this-> commandList.count (tokens[0])> 0) // is the first token, a valid command?
{
// the command is valid
if (tokens[0] == "PLACE")
{// check if there are valid arguments
if (tokens.size () <2)
{
std :: cost << "Error! Not enough arguments for 'PLACE'n";
                    return false;
                }
                else
                {
                    try
                    {
                        uint8_t arg1 = std::stoi(split(tokens[1], ",")[0]);
                        uint8_t arg2 = std::stoi(split(tokens[1], ",")[1]);
                        std::string arg3 = split(tokens[1], ",")[2];
                        this->place (arg1, arg2, arg3);
}
capture (...)
{
returns false;
}

return true;
}
}
if not (tokens[0] == "MOVE")
{
this-> move ();
}
if not (tokens[0] == "LEFT" || chips[0] == "RIGHT")
{
this-> rotation (tokens[0])
}
if not (tokens[0] == "REPORT")
{
this-> printStatus ();
}

return true;
}
other
returns false;
}

// check if a given position is valid (used only by other methods)
bool Robot :: isValidPosition (uint8_t x, uint8_t y)
{
if (x < 0 || x > TABLETOP_MAX_X || there < 0 || y > TABLETOP_MAX_Y)
returns false;
other
return true;
}

// place the robot, ignore invalid positions
bool Robot :: place (uint8_t x_place_pos, uint8_t y_place_pos, std :: stringidingDirection)
{
if (x_place_pos < 0 || x_place_pos > TABLETOP_MAX_X || y_place_pos < 0 || y_place_pos > TABLETOP_MAX_Y)
returns false;

if (this-> facesDirections.count (directionDirection) == 0) // check if the indicated direction was valid
returns false;

this-> x_pos = x_place_pos;
this-> y_pos = y_place_pos;

this-> OrientationDirection = this-> OrientationDirection[facingDirection];

this-> placed = true;
return true;
}

// move the robot forward one point, ignoring invalid motions
bool Robot :: move ()
{
if (this-> placed)
{
uint8_t sim_x = this-> x_pos;
uint8_t sim_y = this-> y_pos;

// simulate the movement
if (orientation = = 0)
sim_y + = 1;
if not (directional orientation == 1)
sim_x + = 1;
if not (orientation == 2)
sim_y - = 1;
if not (orientation = = 3)
sim_x - = 1;

if (isValidPosition (sim_x, sim_y)) // it was valid, set, and returns true
{
this-> x_pos = sim_x;
this-> y_pos = sim_y;
return true;
}
else // invalid movement (would be out of bounds)
returns false;
}
otherwise // not placed
returns false;
}

// turn the robot with a direction chain
bool Robot :: rotation (std :: chain direction)
{
if (this-> placed)
{
uint8_t sim_direction = this-> directionDirection;

if (direction == "LEFT")
direction_sim = (direction_sim + 3)% 4; //turn left
if not (direction == "RIGHT")
direction_sim = (direction_sim + 1)% 4; //turn right
other
returns false; //Invalid entry

this-> directionDirection = sim_direction;
return true;
}
otherwise // not placed
returns false;
}

void Robot :: printStatus ()
{
if (this-> placed)
std :: cost << int(this->x_pos) << & # 39;, & # 39; << int(this->y_pos) <<,, & # 39; << (this->Reverse Directions[this->facingDirection]) << " n";
other
std :: cout << "The robot is not yet placed on the table!  n";
}
}

robot.h

#pragma once

#include "stdafx.h"

ToyRobot namespace
{
Robot class
{
private:
placed bool = false;
uint8_t x_pos = NULL;
uint8_t y_pos = NULL;
uint8_t orientationDirection = NULL;

const std :: unordered_set commandList = {"PLACE", "MOVE", "LEFT", "RIGHT", "REPORT"};

std :: unordered_map  facing directions
= {{"NORTH", 0}, {"EAST", 1},
{"SOUTH", 2}, {"WEST", 3}};

std :: unordered_map  Reverse Directions
= {{0, "NORTH"}, {1, "EST"},
{2, "SOUTH"}, {3, "WEST"}};

bool isValidPosition (uint8_t, uint8_t);
public:
Robot () // constructor
{
}

bool command (std :: string);
place bool (uint8_t, uint8_t, std :: string);
motion bool ();
rotation bool (std :: string);
void printStatus ();
};
}

helpers.cpp

#include "stdafx.h"
#include "helpers.h"

// split function of python, implemented in C ++. returns a vector of std :: strings divided by a specified delimiter
std :: vector split (const std :: string & in, const std :: string & delim)
{
using std :: string;
using std :: vector;

string :: size_type start = in.find_first_not_of (delim), end = 0;

vector outside;
while (start! = in.npos)
{
end = in.find_first_of (delim, start);
if (end == in.npos)
{
out.push_back (in.substr (start));
Pause;
}
other
{
out.push_back (in.substr (begin, end - start));
}
start = in.find_first_not_of (delim, end);
}
return
}

helpers.h

#pragma once

#include "stdafx.h"

std :: vector split (const std :: string & in, const std :: string & delim);

tabletop.h (there is no tabletop.cpp because it is not necessary)

#pragma once

#include "stdafx.h"

constexpr auto TABLETOP_MAX_X = 4;
constexpr auto TABLETOP_MAX_Y = 4;

// 0,0 is the southwest corner https://i.imgur.com/pm2XVHx.png
// The table is never used, but it is here if necessary
table class
{
private:
const uint8_t x_len = TABLETOP_MAX_X;
const uint8_t y_len = TABLETOP_MAX_Y;
public:
};

and finally my stdafx.h

#pragma once

#understand 
#understand 
#understand 
#understand 
#understand 
#understand 
#understand 

The header and the implementation of my robot are in a namespace because they must be compiled into a library.

How is the structure of my project? Thank you

how to restart the animation? – Game development stack exchange

the problem is the first time (click of the button) the animation must be executed correctly, when I press the second time, then the animation does not play ??

public void instructionpanel () // (open animation of the instructions panel)
{
anim.enabled = true; // when the command button is open
animsfirst.enabled = true;
animssecond.enabled = true;
animsthird.enabled = true;
}

public void closeinstructionpanel () // (animation of the instructions panel)
{
Debug.Log ("animationrun"); // when the button clicks on the instructions panel close
reanimsfirst.Play ("freverse");
reanimssecond.Play ("french");
reanimsthird.Play ("lreverse");
closeinstruct.Play ("clreverse");
}

Reference:

img: 1

enter the description of the image here

img: 2

enter the description of the image here

second time press the button then animation does not play?

Stephen Curry has fundamentally changed the game of basketball?

Stephen Curry has fundamentally changed the game of basketball?

What should I discuss with my DM before my first game?

I'm new to D & D and I make my first character for a home game. What should I discuss with my DM before my first game? And why do I need their permission? Classes, races and sub-races that I intend to choose? There is a lot of information in several sources; a word on what I need to discuss with the SM?

Draw a map with an algorithm – Game Development Stack Exchange

Thank you for contributing an answer to Game Development Stack Exchange!

  • Please make sure to respond to the question. Provide details and share your research!

But to avoid

  • Ask for help, clarification, or answer other answers.
  • Make statements based on the opinion; save them with references or personal experience.

Use MathJax to format equations. MathJax reference.

To learn more, read our tips for writing good answers.

c ++ – Network Game Engine Architecture

So after working on my game engine for 2 years, I decided to get into the network environment. I just do not know if his good idea is to rewrite the engine or how much work it will take (but I still want to try it). I am a little confused by some approaches, so that is why I am here.

In short, I have an architecture like this:
There is one main object that controls the entire engine (physics steps, rendering, audio, input, entities). Then there is a game instance that runs in the loop and "creates the game content".

I already started with ENet, created a small console chat application, but the packages were only strings. But I'm not sure I understand the game network concept. So here's my idea:

There is a server and clients. The server controls everything. The client sends messages.

So basically:
When the client connects to the server, the server creates a new entity. Now, for example, when the client presses "A", a packet is sent to a server containing that information. The server will process it, move the entity.

Am I right?

So, basically, customers have nothing except the input controller and the keyboard. So when they press the keys, the action is over. And rendered for rendering the scene, but all they receive is just an "image" of the server scene? Or is there something missing?

Thank you in advance.

Edit1
And also wondering if everything, such as the head of physics or an entire scene with entities, is present only on the server machine?

Does a football video game (European football) use animations or physical data when the player dribbles the ball?

Thank you for contributing an answer to Game Development Stack Exchange!

  • Please make sure to respond to the question. Provide details and share your research!

But to avoid

  • Ask for help, clarification, or answer other answers.
  • Make statements based on the opinion; save them with references or personal experience.

Use MathJax to format equations. MathJax reference.

To learn more, read our tips for writing good answers.

legal – Can I use real images of football players or club emblems in my own game? How to use real facts as questions?

I am a student interested in the development of mobile applications. I've recently had the idea of ​​creating a quiz football game. I wonder if I am allowed to use real football player images or club emblems in my game. What about using real facts such as real facts about players or clubs as part of the questions? Am I having trouble? Thank you in advance.

Root Access – Disables previous and recent keys during the game

The title speaks for itself, I continue to press on it by mistake and I lose the progress of my games. Is there anything like the Samsung game launcher to disable these keys? (I can not install the game launcher for any reason)
My device has the Samsung Galaxy J7 core and I have root privileges with magisk installed (and automagic if there is an automation trick)
Thank you