Java and Libgdx tutorial android 2D car game #1
Hello Welcome to the very first tutorial of our Android 2D car game
series in this tutorial we will just define a few constants that will beneeded into our game. Before we can create a complete game we need
first to define our application window and how big is our world for our object
to interact with, so to begin we create an application window with the
size of WIDTH = 480f; and HEIGHT = 800f; so the display will be
portrait in every mobile device…this width and height will define the
the window for our game, the next attribute will be the HUD_WIDTH &
HUD_HEIGHT, these two attributes will be used to create a window or screen to display our Score and life of the player and will pass this as a parameter into our viewport with camera parameter as well. then finally the next attribute will be the size of our
Game World, which will be the WORLD_WIDTH=6f; WORLD_HEIGHT=10f; remember to always focus on world units when creating your game and not in a pixel as this will lead you in a complex way so always use world unit for an accurate result.
Then the other attribute that we declare will be the WORLD_CENTER_X
= WORLD_WIDTH/2f, WORLD_CENTER_Y=WORLD_HEIGHT/2f and
again this is float type, Now some of you may ask what these two
attributes use, well we need this when we are going to debug our
the world during the development process and we will need this to get the
center of our world using the CameraHelper Class that will be created in
In the next lesson, the other attributes are the following:
================================================================
ATTRIBUTES DESCRIPTION
================================================================
BODY_RADIUS= This will be used for collision detection later on we will
draw shapes with ShapeRenderer class And assign A Math Circle to implement Collision.
PLAYER_SIZE = Will be the size of our player
ENEMY_RADIUS = The body radius of our enemy used also for
collision detection.
collision detection.
ENEMY_SIZE = The respective size of our enemy.
ENEMY_AMBULANCE_TIME = The time that will be used to check
whether it's a time to respawn our ambulance object.
whether it's a time to respawn our ambulance object.
ENEMY_POLICE_SPAWN_TIME = The time used to check the right time to
respawn our Police car
respawn our Police car
ENEMY_TRUCK_SPAWN_TIME =The time used to check the right time to
respawn our Truck car
respawn our Truck car
ENEMY_BLACKVIPER_SPAWN_TIME = The time used to check the right
time to respawn our Truck car
time to respawn our Truck car
ENEMY_TAXI_SPAWN_TIME = The time used to check the right
time to respawn our Taxi car
time to respawn our Taxi car
ENEMY_VAN_SPAWN_TIME = The time used to check the right
time to respawn our Van car
time to respawn our Van car
SCORE_TIMER = The timer used to check when we should add
value to our Score each frame
value to our Score each frame
DIFFICULTY_MEDIUM = A constant value that is defined in Enum class
use for adding difficulty medium level in our game
use for adding difficulty medium level in our game
DIFFICULTY_EASY = A constant value that is defined in Enum class
use for adding difficulty easy level in our game
use for adding difficulty easy level in our game
DIFFICULTY_HARD = A constant value that is defined in the Enum class
use for adding difficulty hard level in our game
use for adding difficulty hard level in our game
PLAYER_LIFE = The life of our Player when the game starts
CODES:
0 Comments