Merged
Conversation
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
Game class implements main loop of the game in a specific frames per second tax
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📤 Pull Request
Description
Simple Game engine built in Game class.
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.
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.