Skip to content

Feature/issue/3 Simple Game engine#6

Merged
Dirack merged 21 commits intodevelop/1.0from
feature/issue/3
May 31, 2020
Merged

Feature/issue/3 Simple Game engine#6
Dirack merged 21 commits intodevelop/1.0from
feature/issue/3

Conversation

@Dirack
Copy link
Copy Markdown
Contributor

@Dirack Dirack commented May 31, 2020

📤 Pull Request

Description

Simple Game engine built in Game class.

GameClass

This engine uses the same simple engine example in the Dankicode classes that runs in a while loop with ticks interval controlled by Thread.sleep() method. This method does Thread to sleep for specific time in mile seconds and can be used to control loop iteration velocity (Frames per second).

Game class offers an interface to control FPS, setFPS() method. This tested in TestGameFramesPerSecond class using Junit.

Resolve #3

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Add images bellow and aditional context if needed

Please describe more information and tests that you ran to verify your changes.
Or add descriptive images.

Dirack added 20 commits May 30, 2020 16:23
Use Junit to test classes
Player and Enemy classes will be Build through a PlayersFactory class.
This startegy is based on Factory method design pattern.
Specify classpath files when running javac to find junit and other classes.
The separator of -cp flag is ':' in linux and ';' on windows
Use this class to build objects from Player and Enemy classes. Pass
1 through constructor method to Build a Player and other number to build
an Enemy
This interface is used to build Player and Enemy objects from
PlayersFactory class.

Hello method is used to identify if it is a Player or Enemy being build
Player is the rectangle controled by user in the Pong Player game
Enemy is the rectangle controled by computer in the Pong Player game
To run the test classes in command line, you have to specify JUnit JAR
file and Hamcrest library JAR file (JUnit depends on it) in the classpath.
Update class to test from command line running 'make test'
Just run a simple test to check if junit-platform is running
Define rules to Makefile to only build test when run 'make test' and
to only clean tests when run 'make cleantest'. Now Makefile only build
test classes if necessary
Test if the objects Player and Enemy are correctlly build by factory
method PlayersFactory.createPongPlayer
Now 'PlayersFactory.createPongPlayer' accepts 'player' or 'enemy' strings
to identify which object to build. If a different string is passed, the
method throws an 'IllegalArguentException' and returns null.

TestPlayersFactory is modified to check for exception case and to pass
string parameters
PongPlayer is a interface to be implementes by Player and Enemy classes.
Those classes are both rectangles that move on screen.

PlayersFactory is a factory class based on factory method design pattern
to build PongPlayer objects, Player and Enemy
Game class starts a new game in an infinite loop, every iteration it updates
and renderizes the game.
Update Makefile to build Game class and do multiple Junit tests.
Use Thread.sleep method and fps variable to control frames per second
tax in main loop of the game
@Dirack Dirack added the enhancement New feature or request label May 31, 2020
@Dirack Dirack added this to the v1.0 milestone May 31, 2020
@Dirack Dirack requested a review from GuilhermeDevW May 31, 2020 16:08
@Dirack Dirack self-assigned this May 31, 2020
@Dirack Dirack changed the base branch from master to develop/1.0 May 31, 2020 16:08
Game class implements main loop of the game in a specific frames per
second tax
@Dirack Dirack linked an issue May 31, 2020 that may be closed by this pull request
4 tasks
@Dirack Dirack mentioned this pull request May 31, 2020
4 tasks
@Dirack Dirack merged commit c7ad611 into develop/1.0 May 31, 2020
@Dirack Dirack deleted the feature/issue/3 branch May 31, 2020 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEA] Build simple game engine [DOC] Build Classes diagram in DIA

1 participant