twiztedcyph / graphicscw Goto Github PK
View Code? Open in Web Editor NEWMy graphics one coursework. Done in C++ using OpenGL and Win32
My graphics one coursework. Done in C++ using OpenGL and Win32
Graphics 1 2D game template =========================== You write your game in GameActivity.h and GameActivity.cpp. It will be a good idea to create other modules/files as well, as if you put all your code in one module it could get out of hand. Textures are loaded using the SOIL library. The source code of SOIL is included. Game Activity ============= Your rendering code goes in the render() method. In the update() method, you step your game/simulation. The deltaT parameter is the amount of time passed since the last update. When moving objects, you use code along the lines of: positionX += velocityX * deltaT If you don't use deltaT, you will find that your game runs at different speeds on different machines, since the speed of your game will be dependent on the frame rate. By using deltaT, you ensure that the simulation steps by the right amount given the time that has elapsed since the last frame Responding to user input (mouse, keyboard) ------------------------------------------ There are two ways of handling user input; event driven or polling. Which approach you take depends on the user action that you are responding to. There are two kinds of action; discrete and continuous. ***DISCRETE ACTION; EVENT DRIVEN*** A discrete action occurs each time the user takes an action, such as shooting a bullet in response to a key press. You trigger these actions in response to events, using the event driven approach. You implement this by adding code to one of the on*() methods (e.g. onMouseDown, onKeyDown, etc), for example: void GameActivity::onKeyDown(int key) { if (key == 'X') // Respond to the X key { // Fire a bullet fireBullet(); } } ***CONTINUOUS ACTION; POLLING*** A continuous action occurs while the user holds a key, or in response to the mouse position. An example is moving a character to the right while holding the RIGHT arrow key. You handle these actions by polling the input state in the update() method. You poll the input state by calling the methods defined by the InputState class (see InputState.h). Here they are for your convenience: bool isMouseButtonPressed(int button) const; // Determine if a button is pressed; 0 = LEFT, 1 = MIDDLE, 2 = RIGHT int getMouseX() const; // Get the mouse X and Y (below) int getMouseY() const; bool isKeyPressed(int key) const; // Determine if a key is pressed For example: void GameActivity::update(double deltaT, double prevDeltaT) { // ... // OTHER UPDATE CODE // ... // The input state can be access from the inputState member variable if (inputState->isKeyPressed(VK_RIGHT)) { characterPositionX += CHARACTER_SPEED * deltaT; } // ... // OTHER UPDATE CODE // ... } Start and end screen ==================== The start and end screens are impelemented in the StartScreenActivity and EndScreenActivity classes. You will want to change the start_screen.png and end_screen.png image files at least, to personalise them. You can also modify StartScreenActivity and EndScreenActivity to alter their behaviour if you wish. They work the same way as GameActivity Adding new activities ===================== If you need to implement new activities besides game, start screen and end screen, you will need to add member variables for them in the OpenGLApplication class. You will also need to construct and destroy them in the OpenGLApplication::initialise and OpenGLApplication::shutdown methods.
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.