How to make it so the game waits on player input for a dialog system in Godot?

So i have most system set up im just at loss on make it so that the player has to click through the dialog. Currently all the dialog is stored in text files that are read into dictionary’s like so.

var dic = {}

func test():
    var index = 1
    popup_centered(Vector2(0,2000))
    var line = dic(str(index))
    $Text.set_text(line)


#loads file into dictionary
func load_file(filepath):
    dic = {}
    var file = File.new()
    file.open(filepath, 1)
    var index = 1
    while not file.eof_reached():
        var line = file.get_line()
        print("the line:")
        print(line)
        dic(str(index)) = line
    index += 1
    file.close()
    print(dic)
    test()

Where the test function is like i said above i want the code to wait for the players input and print the next line in the dictionary and then close when the dictionary is empty. Being new to Godot i dont know if there is a simple way to do this. Any help is appreciated and thank you in advance.

Also aside, i know there are a lot of plug-ins for Godot that can handle dialog if i download them, but i want to build this myself so i can learn, so please don’t just say use a plug in.

I want to create a 3D game in unity for wolf and sheep game. So, how can I set up pieces and move them using C# code?

This is the approach that I have made so far in the code that I have written. Based on the results in unity, I can see 4 white pieces on one end and 4 black pieces on the opposite end. When I try to move the pieces, it moves diagonally once. When I try to move the second piece it goes back to the original settings.
What I am trying to do here is that I want to set up 4 white pieces on one end and 1 black piece on the opposite end and to move them diagonally.
The code is given below:-

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class GC : MonoBehaviour
{
(Tooltip(“The number of squares wide”))
public int width = 10;
(Tooltip(“The number of squares deep”))
public int depth = 10;
(Tooltip(“The prefab for the light board tile”))
public GameObject tileLightPrefab;
(Tooltip(“The prefab for the dark board tile”))
public GameObject tileDarkPrefab;
(Tooltip(“The prefab for the light playing piece”))
public GameObject pieceLightPrefab;
(Tooltip(“The prefab for the dark playing piece”))
public GameObject pieceDarkPrefab;
(Tooltip(“Any string put in messagetext.text will appear the the left of the screen”))
public Text messageText;
(Tooltip(“Reference to the camera to be used in determining the mouse position”))
public Camera cam;

// The following is used if you wish to have mouse input
private Vector2 mousePos;   // Can be used to hold the mouse screen position 
private Vector3 mouse3DPos; // Can be used to hold the mouse position on the ground (ignore y axis)
                            // To get the mouse position use the following code in the update method
                            //    mousePos = Input.mousePosition;//gets mouse postion
                            //    // Convert mouse screen position to a position on the ground
                            //    mouse3DPos = cam.ScreenToWorldPoint(new Vector3(mousePos.x, mousePos.y, cam.transform.position.y));

public const int NumberOfPieces = 8;   // A constant used to hold the number of pieces created


GameObject() Piece = new GameObject(NumberOfPieces);     // This array will hold all the playing pieces
Vector3() Target = new Vector3(NumberOfPieces);       // This array will hold the target for each playing piece

GameObject() PiecePrefab = new GameObject(2);   // Used to hold the piece prefabs for easier selection

public float Speed = 10f;   // Speed to move peice in m/s
int Movethepiece = 0;        // Used as index to piece array to indicate piece to be moved    
public float PieceHeight = 0.1f; // The height the pieces should be placed above the tiles

public enum GameState { Begin, Player1, Player2, End };
public GameState gameState;
public bool isGameInitialised = false;
public Vector3 gizmoPosition = Vector3.zero;

// Start is called before the first frame update
void Start()
{
    InitialiseBoard(width, depth);  // Call method to create the playing board
    messageText.text = "";  // Any string assigned to this will appear on the left of the screen 

    PiecePrefab(0) = pieceDarkPrefab;  // Put the pieces prefabs into an array to be able to use the index
    PiecePrefab(1) = pieceLightPrefab;   //  to select a light or dark piece.
    //piece.clear();
    int i = 0;
    while ( i < NumberOfPieces)    // While Loop to initialise the playing pieces
    {
        Target(i) = new Vector3(i, PieceHeight, 0); // Target holds the initial piece position
        Piece(i) = Instantiate(PiecePrefab(i % 2), Target(i), Quaternion.identity);   // Create a new playing piece
        i++;
    }
    
}
void InitialGame()
{
    for (int i = 0; i < NumberOfPieces; i++)    // Loop to initialise the playing pieces
    {
        Target(i) = new Vector3(i, PieceHeight, 9 - (i % 2 * 9)); // Target holds the initial piece position
        Piece(i).transform.position = Target(i);
    }
    Target(1) = new Vector3(1f, PieceHeight, 1f);
    Piece(1).transform.position = Target(1);
    isGameInitialised = true;
} 

// Method:  InitialiseBoard
// Input:   int width - the width of the board in number of tiles
//          int depth - the depth of the board in number of tiles
// Output:  none
// Description:
//      Creates a draughts or checkers board of size given by the inputs.
//      It assumes that the first tile is at position 0,0 and that the tile are 1x1 in size.
private void InitialiseBoard(int width, int depth)
{
    for (int x = 0; x < width; x++)  // Loop through each row of the board
    {                               // x indicates the width position of tile
        for (int z = 0; z < depth; z++) // Loop through each column of the board
        {                               // z indicates the depth position of tile
            // By adding x and z we get a number that alternates between odd and even.
            // Taking the modulus'%' of 2 (i.e. dividing by 2 and taking the remainder)
            // we get a remainder of 0 or 1. We can now check if the number is even by comparing with 0.
            // This allows us to select the light or dark coloured tile to create.
            if ((x + z) % 2 == 0)     // Select light or dark coloured tile. 
            {
                // Create new instance of Light Tile
                Instantiate(tileLightPrefab, new Vector3(x, 0, z), Quaternion.Euler(0f, 0f, 0f));
            }
            else
            {
                // Create new instance of Dark Tile
                Instantiate(tileDarkPrefab, new Vector3(x, 0, z), Quaternion.Euler(0f, 0f, 0f));
            }
        }
    }
}

// Update is called once per frame
void Update()
{
    switch (gameState)
    {
        case GameState.Begin:
            Begin();
            break;
        case GameState.Player1:
            MovePiece();
            break;
        case GameState.Player2:
            MovePiece();
            break;
        case GameState.End:
            break;

    }
    //MovePiece();
}
void Begin()
{
    if (!isGameInitialised)
    {
        InitialGame();
    }
    messageText.text = "Wolf and Sheep GamenInstructions:-nPress Spacebar Enter to startnPieces move diagonal onlynLight piece only move forwardn Dark piece move back and forth";
   
    if (Input.GetKeyDown(KeyCode.Space))
    {
        gameState = GameState.Player1;
    }
}

void MovePiece()
{
    Vector3 tempTarget;

    if (Input.GetKeyDown(KeyCode.Space))    // Check for space bar to change piece to be moved
    {
        Movethepiece++;  // Space bar used to increment the piece to be moved
        if (Movethepiece >= Piece.Length)  // check that the piece to moved is valid, i.e. not greater that the pieces available
        {
            Movethepiece = 0;    // If not valid then wrap around to zero.
        }

    }
    if (gameState == GameState.Player1)
    {
        messageText.text = "Player 1n";
    }
    else
    {
        messageText.text = "Player 2n";
    }
    messageText.text = "Piece To Move: " + Movethepiece.ToString();  // Tell the play which piece is to be moved.

    tempTarget = Target(Movethepiece);
    if (Input.GetKeyDown(KeyCode.W))
    {
        if (tempTarget.z < (width - 1))
        {
            tempTarget.z += 1;
            tempTarget.x += 1;
            if (gameState == GameState.Player1)
            {
                gameState = GameState.Player2;
            }
            else
            {
                gameState = GameState.Begin;
                isGameInitialised = false;
            }
        }

    }
    
    if (Input.GetKeyDown(KeyCode.S))
    {
        if (tempTarget.z > 0)
        {
            tempTarget.z -= 1;
            tempTarget.x -= 1;
            if (gameState == GameState.Player1)
            {
                gameState = GameState.Player2;
            }
            else
            {
                gameState = GameState.Begin;
                isGameInitialised = false;
            }
        }

    }
    Target(Movethepiece) = tempTarget;

    Vector3 position = Piece(Movethepiece).transform.position;
    if (position != tempTarget)
    {
        if (position.z != tempTarget.z)
        {
            if (position.z < tempTarget.z)
            {
                position.z += Speed * Time.deltaTime;   // Look up LERP
                if (position.z > tempTarget.z)
                {
                    position.z = tempTarget.z;
                }
            }
            else
            {
                position.z -= Speed * Time.deltaTime;
                if (position.z < tempTarget.z)
                {
                    position.z = tempTarget.z;
                }
            }
        }
    }
    Piece(Movethepiece).transform.position = position;
    if (!IsTileOccupied(tempTarget))
    {
        Target(Movethepiece) = tempTarget;
    }

    if (Piece(Movethepiece).transform.position != Target(Movethepiece))
    {
        Piece(Movethepiece).transform.position = Vector3.Lerp(Piece(Movethepiece).transform.position, Target(Movethepiece), Speed * Time.deltaTime);
    }
    ShowSelection(Piece(Movethepiece).transform.position);

}
    public void ShowSelection(Vector3 position)
    {
    gizmoPosition = position;
    }
    public void OnDrawGizmos()
    {
    Gizmos.color = Color.green;
    Gizmos.DrawSphere(gizmoPosition, 0.25f);
    }

    public float MoveAxis(float targetAxis, float currentAxis)
    {
    if (currentAxis < targetAxis)
    {
        currentAxis += Speed * Time.deltaTime;   // Look up LERP
        if (currentAxis > targetAxis)
        {
            currentAxis = targetAxis;
        }
    }
    else
    {
        currentAxis -= Speed * Time.deltaTime;
        if (currentAxis < targetAxis)
        {
            currentAxis = targetAxis;
        }
    }
    return currentAxis;

    }

    bool IsTileOccupied(Vector3 targetTile)
    {
    bool isTileOccupied = false;
    for (int i = 0; i < Target.Length; i++)
    {
        if (Target(i) == targetTile)
        {
            isTileOccupied = true;
        }
    }

    return isTileOccupied;
    }

}

Yet another implementation of Conway’s Game of life in Haskell

(Sorry for my bad English)
Hi, I’m interested in getting feedback of my own implementation of Conway’s Game of Life.

Some details:

  • Uses gloss for animation
  • Uses rio for shorter dependency list

My implementation suffers from performance issue when the population grows larger than 2000 cells.

My code:

module Main where

import           Lib
import qualified RIO.ByteString                as B
import           System.Environment
import qualified Graphics.Gloss                as G

main :: IO ()
main = do
  (file)      <- getArgs
  initialGrid <- B.readFile file
  let patt = parse initialGrid
  G.simulate G.FullScreen G.white 20 patt golPic (_ _ ps -> eval ps)

golPic :: (Point) -> G.Picture
golPic ps =
  G.pictures ( G.translate (fromIntegral x * dIMENSION) (fromIntegral y * dIMENSION) (G.color G.black (G.rectangleSolid dIMENSION dIMENSION)) | (x, y) <- ps )

parse :: B.ByteString -> (Point)
parse bs = map fst . filter ((== 42) . snd) . concatMap ((x', xs) -> ( ((y', -x'), c) | (y', c) <- zip (1 .. length xs) xs )) $ zip (1 .. length bs') bs'
  where bs' = map B.unpack $! B.split 10 bs

dIMENSION :: Float
dIMENSION = 10
module Lib where

import qualified RIO.Map                       as M

type Point = (Int, Int)

adjacents :: Point -> ((Point, Int))
adjacents (x, y) = ( ((x + m, y + n), 1) | m <- (-1, 0, 1), n <- (-1, 0, 1), (m, n) /= (0, 0) )

eval :: (Point) -> (Point)
eval cs =
  ( x
  | (x, y) <- M.toList . M.fromListWith (+) . concatMap adjacents $ cs
  , case y of
    2 -> x `elem` cs
    3 -> True
    _ -> False
  )

Any suggestion is welcome.

movement – Any ideas as to how a role playing game collision can be made in pygame WITHOUT the use of sprites

Thanks for contributing an answer to Game Development Stack Exchange!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

Use MathJax to format equations. MathJax reference.

To learn more, see our tips on writing great answers.

Storing,versioning game assets [closed]

What do you use nowadays to share/sync large game assets like textures, sound etc.? Is Perforce still an industry standard for that?

I can’t choose between:

  • Git LFS
  • Perforce
  • Dropbox/Mega/Google Drive

javascript – Html5 canvas game friction

I’m having a problem applying friction to my ball. I mean it works and it stops when I release the key but the first time I press the key to move it like stops for a second like the speed drops all of the sudden and then it keeps going normally.

I’ll leave the link to my source code here so you can hopefully help me. I think the problem is in the ball class or in the controller class but I can’t figure it out.

Thank you

https://github.com/0MyNick0/ball_game.git

google play services – Leaderboard broke Ads from displaying? | Game Maker Studio 2

In my game I want to add leaderboards to it so people can see the highest score and compete for it. My game was displaying ads correctly before adding the leaderboard code. I followed these 2 tutorials to add leaderboards to my game:

https://help.yoyogames.com/hc/en-us/articles/360004274212

https://help.yoyogames.com/hc/en-us/articles/360004359432

From adding leaderboards to my game, it has stopped the advertisements from displaying. I don’t understand why?

game development – “Serious” work with experience of Python Turtle Graphics

Writing games with Turtle Graphics may seem like a fairly trivial programming task.
However, in my experience it has involved a fairly deep knowledge of several topics including:

  • Event Driven Programming
  • OOP
  • Mathematics
  • Game AI such as Minimax, Monte Carlo
  • Algorithms and Data structures e.g. A* for path finding in a maze, using a priority Queue based on heapq
  • Complex simulations of physical phenomena – astronomical, particle collisions etc.

I’ve become pretty good at writing games using Turtle Graphics, and believe the module is a lot more powerful than it’s often given credit for.

I’m curious to know if becoming an expert using Turtle Graphics for games and simulations is ever likely to be taken seriously as “development” experience in terms of landing a software development job?

Perhaps if Turtle Graphics is not considered serious enough, since the Python Turtle module is built on Tkinter, would becoming an expert at Tkinter GUI programming do the trick?

anti cheat – Is reobfuscating javascript every time the page is loaded a valid option for a multiplayer game?

I am looking for ways to prevent cheating on a multiplayer browser game. I saw this answer where it was mentioned that obfuscation is not an effective technique.

My plan is not only to obfuscate the code differently every time the page is loaded but periodically change the protocol that the client uses to communicate with the server. This would mean that even if they were able to deobfuscate the client-side code, they would need to update the protocol every time I changed it or they wouldn’t be able to communicate with the game servers. I know that this will be difficult to implement, but I believe that I can do it.

Would this work? I know that it’s impossible to outright prevent cheating, but I believe that this would make it extremely difficult.

game design – extend glicko2 for multiplayer

I want to have a commercial rating system for a multiplayer card game (not just 1:1) but n:n. There is trueskill from microsoft – but it is restricted for non-commercial only and has some known problems.

For this reason I thought about extending glicko2. Most simple approach would be to take the average of all other players = player2:

Example glicko2:

  1. Assume you have 4 player playing a card game.
  2. Assume one Game consists of 4 Rounds
  3. After playing 4 rounds:
    • Player 1 = 9 Points
    • Player 2 = 2 Points
    • Player 3 = 1 Points
    • Player 4 = 20 Points
  4. Evaluate WIN, LOSS, DRAW as follows:
    • Average all Points = 32/4 = 8
    • 20% above average = 9.6 points
    • If you have 20% above average -> Player 4 is a winner
    • If you have >average and <20% above average -> Player 1 has a DRAW
    • If you have <average you lost -> Player 3, Player 4
  5. Rate using average based glicko2
  • Consider all player already have a rating mu, phi sigma
  • the new ratings according to above Game (4 Rounds) is computed as follows:
   # see: also https://github.com/sublee/glicko2/blob/master/glicko2tests.py
   env = Glicko2(tau=0.3)
   player1_new_rating = env.rate(player1_rating, ((DRAW, rating_mean_2_3_4))
   player2_new_rating = env.rate(player2_rating, ((LOSS, rating_mean_1_3_4))

Questions:

  1. Are there any other good methods for rating multiplayer player card games?
  2. How would you do it?