Skip to content

Player Gravity

SirAardvark edited this page Aug 30, 2021 · 2 revisions

Usage

Implementation

All code is in PlayerActions

The old way player movement was initiated:

OLD VARIABLE - private Vector2 walkDirection = Vector2.Zero.cpy();

The new way player movement is initiated. The player is added with -1f (1 m/s force downwards) instead of not moving on spawning. The gravity variable is used to check the player is not moving. e.g. not moving up, down, left or right.

// Sets gravity to 1 m/s for comparing
private static final Vector2 gravity = new Vector2 (0, -1f);
// Sets player movement and adds gravity of 1 m/s
private Vector2 walkDirection = new Vector2 (0, -1f);

Any where that used the below has been replaced with

// OLD
variable = Vector2.Zero;
// NEW 
variable = gravity;

Table of Contents

Home

Introduction

Main Menu

Main Game Screen

Gameplay

Player Movement

Character Animations

Enemy Monster Design and Animations

Game basic functionalities

User Testing

GitHub Wiki Tutorial

Game Engine

Getting Started

Documentation

Entities and Components

Service Locator

Loading Resources

Logging

Unit Testing

Debug Terminal

Input Handling

UI

Animations

Audio

AI

Physics

Game Screens and Areas

Terrain

Concurrency & Threading

Settings

Troubleshooting

MacOS Setup Guide

Clone this wiki locally