beghelli / atomscollector Goto Github PK
View Code? Open in Web Editor NEWEducational game about atoms and molecules
Educational game about atoms and molecules
ATOMS COLLECTOR It is a game where the player has to collect atoms to produce a desired number of an specific molecule. In order to collect the atoms, the player has to touch them in an specific way. The stage is full of different types of atoms that keep moving in different speeds and that are identified them by their atomic number (isotopes of the same atom will be identified by their atomic mass). The player has some passive and active abilities that will help collecting the atoms. LEARNING OBJECTIVES We hope that the game will help students learning / memorizing: - atoms and their basic particles - isotopes - periodic table, atomic mass, atomic number - molecules and molecular formula - fission and fusion reactions PLAYER ABILITIES The player can: - move into any direction on the stage - use A W S D keys to move left, up, right and down. Use two directional keys to move diagonally. - run - while moving, holds SHIFT key to run - shoot a neutron into any direction - aim using the mouse and shoot by clicking any mouse button. Holding the mouse button will charge the neutron with more energy and releasing the button will shoot the neutron charged with extra energy. - collect atoms it touches - move close to an atom until it touches the front part of the player while holding SPACE key. A player and atom collision will happen if: - the player doesn't hold the SPACE key while touching the atom - or the atom touches the back part of the player - player has no room in the atom containers to contain the touched atom ATOM CONTAINERS The player has containers that will hold the collected atoms. On each stage the player will have available a number of containers sufficient to hold all the atoms that form the molecule plus one. The extra one will contain atoms that the player collects but are not part of the molecule. ATOM AND PLAYER COLLISION If an atom touches the player while it is not holding the SPACE key, the atom and the player will collide. The atom will move to an opposite direction and the player will consume energy to absorb the impact. The higher the atomic mass and or atom velocity, the higher energy the player will have to spend to survive the collision. REUSING ATOMS The collected atoms that are not part of the desired molecule can be reused to: - fuel the energy generator (for simplicity we can assume fission and fusion processes can easily happen with any type of atom, a more realistic approach to the energy generation can be a future expansion of the game) - provide neutrons for the player to shoot ENERGY To perform any ability and to defend itself from atoms collisions, the player consumes energy. An energy bar is displayed to the player so it knows how much energy left it has to complete the atoms collection. The energy generator can be fueled by the collected atoms that are not part of the desired molecule. It will slowly produce more energy for the player to consume, filling the energy bar while it consumes atoms (therefore emptying the other atoms container). The player can also fill the energy bar (a high amount) if it can collect, in a short period of time, 3 hidrogen atoms in sequece: - hidrogen - deuterium - tritium The collection combo will trigger a fusion process that will generate an atom of helium (that will appear in the stage coming out from the player position) and a lot of energy (filling the energy bar). The fusion process will only happen if the player has enough energy to trigger it after the 3 atoms are collected. ATOMS INTERACTION Using the neutron shot, the player can interact with atoms that are on the stage to: - change the atom direction - create isotopes by adding neutrons to their nucleous - fission an atom into two The amount of energy required for each operation increases and the player can adjust the shot energy level, limited only by the amount of available energy it has. These 3 atoms interactions help the player to reach the goal of collecting the correct atoms that will produce the desired molecule. For example: - the molecule to build is water - the player didn't collect many hydrogens yet - the stage only has a few Helium atoms and lots of other atoms In this scenario, the player can collect enough atoms to produce energy and, when it has enough energy, shoot a high energized neutron into a Helium atom to break it into two hydrogen (very simplistic fission, but necessary to make the game fun as well) and then collect the resulting hydrogens. The energy released by the fission will speed up nearby atoms and the player might have to "defend" itself from them using the neutron shot to change their direction. Another scenario is when there are lots of available atoms of hydrogen and the player wants to produce a lot of energy, it can shoot neutrons at the hydronge atom to create isotopes and then collect them sequentially to produce energy from fusion. ATOMS COLLECTION COMBO Players can also directly produce the desired molecules if they collect atoms in the correct order of the molecule formula during a certain small period of time. Using the water molecule example, the player would have to collect 2 hydrogen and 1 oxygen sequentially to directly produce the molecule. When that happens, the collected atoms don't fill the containers, they are directly used to produce the molecule. This allows skilled players to produce more molecules then what their containers capacity can hold in atoms. WHEN THE GAME IS OVER When the player runs out of energy or when the containers to hold the desired atom containers are full. Either way, the player will receive its score based on the number of molecules it was able to produce. COMPILE (REFERENCE DEPENDENCIES, DEV) Windows g++ -o game main.cpp ./engine/Core.cpp ./engine/Game.cpp ./engine/MetricManager.cpp ./engine/Entity.cpp ./engine/GameEntity.cpp ./gameEntities/Atom.cpp ./gameEntities/Player.cpp ./gameEntities/Bullet.cpp ./UIEntities/ScoreBoard.cpp ./scenes/HuntAtoms.cpp ./scenes/support/AtomGenerator.cpp ./data/AtomDAO.cpp ./data/MoleculeDAO.cpp ./data/LevelDAO.cpp ./engine/support/EntityRepository.cpp ./engine/support/CollisionDetector.cpp ./engine/support/ScreenWriter.cpp ./engine/support/Message.cpp ./engine/support/EventsManager.cpp ./engine/support/Event.cpp ./events/PlayerAndAtomCollided.cpp MyGame.cpp -IC:\dev\SDL2-2.26.3\x86_64-w64-mingw32\include -LC:\dev\SDL2-2.26.3\x86_64-w64-mingw32\lib -LC:\dev\SDL2_ttf-2.20.2\x86_64-w64-mingw32\lib -I./gameEntities/ -I./scenes/ -I./scenes/support/ -I./UIEntities/ -I./events/ -I./engine/support/ -I./engine/ -I./data/ -I. -lmingw32 -lSDL2main -lSDL2 -lSDL2_ttf Linux Install SDL2 and SDL2_ttf (for text display) libraries: - sudo apt-get install libsdl2-dev - sudo apt-get install libsdl2-ttf-dev - sudo apt-get install libsdl2-image-dev g++ -o game main.cpp ./engine/Core.cpp ./engine/Game.cpp ./engine/MetricManager.cpp ./engine/Entity.cpp ./engine/GameEntity.cpp ./gameEntities/Atom.cpp ./gameEntities/Player.cpp ./gameEntities/Bullet.cpp ./UIEntities/ScoreBoard.cpp ./scenes/HuntAtoms.cpp ./scenes/support/AtomGenerator.cpp ./data/AtomDAO.cpp ./data/MoleculeDAO.cpp ./data/LevelDAO.cpp ./engine/support/EntityRepository.cpp ./engine/support/CollisionDetector.cpp ./engine/support/ScreenWriter.cpp ./engine/support/Message.cpp ./engine/support/EventsManager.cpp ./engine/support/Event.cpp ./events/PlayerAndAtomCollided.cpp MyGame.cpp -I./gameEntities/ -I./scenes/ -I./scenes/support/ -I./UIEntities/ -I./events/ -I./engine/support/ -I./engine/ -I./data/ -I. -lSDL2main -lSDL2 -lSDL2_ttf -lSDL2_image COMPILE AND LINKER COMMAND (STATICALLY INCLUDE DEPENDENCIES, PRODUCTION) Windows g++ -o game main.cpp ./engine/Core.cpp ./engine/Game.cpp ./engine/MetricManager.cpp ./engine/Entity.cpp ./engine/GameEntity.cpp ./gameEntities/Atom.cpp ./gameEntities/Player.cpp ./gameEntities/Bullet.cpp ./UIEntities/ScoreBoard.cpp ./scenes/HuntAtoms.cpp ./scenes/support/AtomGenerator.cpp ./data/AtomDAO.cpp ./data/MoleculeDAO.cpp ./data/LevelDAO.cpp ./engine/support/EntityRepository.cpp ./engine/support/CollisionDetector.cpp ./engine/support/ScreenWriter.cpp ./engine/support/Message.cpp ./engine/support/EventsManager.cpp ./engine/support/Event.cpp ./events/PlayerAndAtomCollided.cpp MyGame.cpp -IC:\dev\SDL2-2.26.3\x86_64-w64-mingw32\include -LC:\dev\SDL2-2.26.3\x86_64-w64-mingw32\lib -LC:\dev\SDL2_ttf-2.20.2\x86_64-w64-mingw32\lib -I./gameEntities/ -I./scenes/ -I./scenes/support/ -I./UIEntities/ -I./events/ -I./engine/support/ -I./engine/ -I./data/ -I. -lmingw32 -lSDL2main -lSDL2 -lSDL2_ttf -lrpcrt4 -mwindows -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid -static
Players should be able to produce the level desired molecule by realizing a collection combo (see #16 ), so they can produce even more molecules compared to what they could if they just depended on their atom recipients capacity.
Player should have the ability to collect atoms. This behavior is implemented now by just allowing the player to touch the atom and collect it.
We need to make this process a little bit harder so it is more challenging and involves a little bit more skill from the player.
The collection should only happen if the player is:
To avoid spamming the SPACE key, holding it should consume energy, so players will only be holding it when they really need to.
If the player touches an atom without completing all necessary actions listed above, the collection should not happen. For now, let's not change anything related with both entities. The player and atom collision behavior should be implemented in another issue.
Using the atoms repository data, we should build an atom generator to feed the hunt atoms scene. The generator must know which atoms are part of the wanted molecule, so it can balance the number of times these atoms will appear.
When a player start to build a combo the game should let it very clear.
When user press enter to start the game, when it confirms the level start
We should make the id an static attribute and let the client code get it from there when registering listeners
When a shot is made with the right energy level, it can cause an atom to fission. We need a sound to represent the neutron hitting the atom and causing the fission. The process (fission) is instantaneous, so just the sound of the fission is enough.
Filling both should feel special to the player, we could try to add a little animation of the bar filling up and a glow around the bar, for example.
Players will be able to perform a combo (see #16 ) and generate a high amount of energy if they complete the combo and have enough energy to trigger the fusion process.
The atoms that are not required to build them molecule can be used to produce energy for the player.
The energy production process happens automatically and should start as soon as the player collects non requested atoms. As the energy bar rises, the other atoms recipient should start emptying. When the other atoms recipient is empty, the energy bar should not increase. When the energy bar is full, the others recipient should not decrease.
Players can perform combos when collecting atoms. A combo is a correct sequence of atoms collected in a certain limited period of time.
Two scenarios where a collection combo can happen:
In both scenarios, the combo experience should be the same:
We have to consider how we can differentiate the lighter and heavier atoms. But generally the atoms should look alike.
Bullets that are created right after another is destructed are being destructed when a third one reaches the screen limit first.
Players should be able to shoot an atom and start a fission process, so they have more influence on the atoms presented in the level and are able to complete their task (collect certain atoms) more easily.
The shot to start a fission reaction in the atom has to have a high energy level (consumes a lot of energy from the player). That level should be fixed for now, not depending on anything external.
Once the shot hit the atom, the original atom will disappear and two or more atoms (result of the fission) will spawn exactly where the original atom was. The energy released in the reaction should move all nearby atoms (including the resulting ones) to all directions. The angle should be calculated from the last x and y of the original atom that was shot to the other nearby atoms. The angle for the atoms that are products of the reaction should be random, as they will spawn right into the same x,y coordinate.
Player shooting should produce a sound. The shot has, at least, 3 different levels of energy. We could make 3 different sounds, similar but different in intensity, for each level of energy.
Players should be able to see how many molecules they already produced during the level (realizing atoms collection combos). The number of produced molecules should only display the ones that are already produced, not the amount that is possible to produce with the current stored atoms.
When an atom collides with a player
It has to do with player acceleration having a double value (instead of integer) and adding the acceleration to the velocity and calculating the next position. Not sure why the issue relates to the left and up, but I suspect it has to do with the operation, when moving up and left we decrease the player x and y. When moving to down and right, we increase.
The normal collision will make the neutron disappear and the atom change direction.
Player should be able to charge a neutron with more energy before shooting it, so it can either cause an atom fission or incorporate a neutron into the atom's nucleus.
To charge the player must hold the mouse click and release it whenever the energy level in the neutron is sufficient to do what the player wants to do.
Players should be able to know the level objective (which molecule to build, the molecule formula and information about the molecule) before actually starting playing the level.
All that information should be displayed and the player can decide to actually start playing the game by pressing ENTER.
Right now the entity class is responsible for not only defining the assets to be used (texture, text, sounds in the future) but also to know how to load them and add them into the assets manager. This is done by the entity load method receiving all the assets managers that the entity will need to load things into the managers. Right now we have only the texture, but we need also the text manager (the screen writer) and in the future sound manager.
We could improve this by allowing the entity to just define the asset it wants to use and let the asset manager to know how to load it. We could also set the loaded texture as an entity attribute that points to the one loaded by the texture manager, so the entity render method won't need the texture manager as a parameter.
While playing the level, players should be able to see the name of the molecule that's required on that level. They should also be able to see the atom acronym next to each atom recipient.
On each level players should have as many atom recipients as the number of unique atoms the molecule has, plus one. The extra one is to store other atoms that are not part of the wanted molecule formula.
A unit should be used whenever we need to handle dimensions in the game. Then we can calculate how many pixels each unit will have based on the screen resolutions. Doing that we will be able to present the game correctly to many resolutions, instead of just one.
See how unity's approach on this problem: https://blog.unity.com/technology/choosing-the-resolution-of-your-2d-art-assets
The other atoms recipient should also be a source for the player shots. Each player shot needs to decrease the amount of other atoms stored in the recipient.
If the player doesn't have any other atom store, it can't shoot.
The engine should be able to reproduce sound (in game effects and music background)
When an atom is collected by the player
Whenever an atom collides with the player without the player being able to collect it (see #8 ), then we have a player and atom collision.
The atom should behave like it is colliding with a neutron (see #7 ) (change direction based on its own direction, mass and velocity and the direction, mass and velocity of the player).
The player should spend energy to be able to absorb and support the collision, suffering the same physical effects that the atom.
It could be nice to have some electrons animation around the atoms, even though we won't be able to represent them all because of the atom sprite size.
Players should open the game and see a screen with the game name and an option to start it.
Atom and neutron entities can collide and the result of that collision depends on the energy of the neutron. If the energy level is minimum, the only thing that will happen is that the atom direction should change according to the direction and velocity of the neutron and the direction, velocity and atomic mass of the atom.
The heavier and faster the atom, the less it will have its trajectory changed.
Players should be able to shoot an atom and create an isotope by providing an extra neutron to the atom nucleus, so they can better influence the game scene and enable them to combo for energy, for example.
The shot to create an isotope should have a certain energy level that the player will have to reach by holding the mouse button. The energy level to create an isotope should be fixed for now, not depending on anything else.
Once the shot is made and the atom is hit, all the physics of the simple atom collision (see #7 ) should happen, but the atom now should be represented by a new atomic mass.
The engine should be able to run animations
To perform any ability (active or passive) the player has to spend energy.
We should display an energy bar that will represent the amount of energy the player still has and will decrease based on the player actions.
Players should see the number of produced molecules at the end of the level and an option to go to the next level.
When a shot is made with the right energy level and the atom that is hit has an isotope version, a sound to represent the neutron being absorbed by the atom nucleus should be played.
We need a repository to hold information about all possible atoms that will appear in the game. The atom attributes will be:
That data should be indexed by strings built based on the following: atomic number + acronym + atomic mass. So a Hydrogen would be 1H1, a Hydrogen isotope could be 1H2 or 1H3, Lithium would be 3Li6, etc.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.