The Ring programming language version 1.5.4 book - Part 48 of 185Mahmoud Samir Fayed
This chapter discusses creating a game engine for 2D games in Ring. The project has several layers: a games layer that uses declarative programming to create games, game engine classes that use object-oriented programming, an interface layer that hides the details of the graphics libraries, and graphics library bindings that were created using procedural programming. The game engine includes classes like Game, Sprite, Text, and Sound that can be used to easily create 2D games. Examples are provided of simple games created using the engine.
Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, and 2D video frame buffer - a core component of the PDK.
SDL2 Game Development VT Code Camp 2013Eric Basile
This document provides an overview of the Simple DirectMedia Layer (SDL) library for 2D game development. It introduces SDL, its history and creators, how it provides cross-platform access to graphics, audio, input, and more. It covers initializing SDL, creating windows and renderers, basic event handling, 2D drawing, loading images and sounds, and the basic structure of an SDL game loop. Extensions like SDL_image and SDL_mixer are discussed. Sample code demonstrates common SDL tasks.
Cross-platform game engine development with SDL 2.0Leszek Godlewski
Lecture from the WGK 2013 game development conference
The SDL library (Simple DirectMedia Layer) - known as "the open source response to DirectX" - lets you forget about all the boilerplate in game development on platforms ranging from Windows, through Linux and Mac OS X, to iOS and Android. While still in active development, version 2.0 of SDL provides new and improved functionality, including touch input and force feedback support. It also ships with the Steam Linux Library. This lecture provides an overview of the library's capabilities and some useful tricks.
XNA is a framework for creating 2D and 3D games for Windows Phone 7. It includes tools for game development and resource management. The XNA framework provides classes to create gameplay and manage game resources like textures, models, and scripts. When an XNA game runs, it loads resources at start up, then repeatedly updates the game world based on input and draws the updated world. The core methods that drive this cycle are LoadContent, Update, and Draw. LoadContent loads resources. Update handles game logic and state changes. Draw renders the current game state to the screen.
This document provides an overview of using the XNA framework to create games for Windows Phone 7. It discusses that XNA is a framework for writing 2D and 3D games. It includes tools for game production and resource management. The document explains how to load game assets, create sprites, and use the XNA game class methods like LoadContent, Update, and Draw to initialize resources, update the game world, and draw to the screen. It provides an example of creating a simple game that draws a texture and moves it by updating its rectangle position in the Update method.
The Ring programming language version 1.5.2 book - Part 47 of 181Mahmoud Samir Fayed
This document describes a game engine project that uses multiple programming paradigms. The project has four layers: 1) a games layer that uses declarative programming to create games, 2) game engine classes that use object-oriented programming, 3) an interface layer that hides graphics library details using procedural programming, and 4) graphics library bindings implemented in C. The document provides details on the classes and functions available in each layer. It also outlines some example games that can be built with the engine.
This document provides an overview of using the libGDX framework to implement a simple 2D game in Java. It discusses topics such as setting up the starter class, loading assets like images and audio, rendering with an orthographic camera, sprite batch for drawing textures, handling input, collision detection using rectangles, and more. The goal is to demonstrate the basic building blocks for creating a 2D game with libGDX.
The Ring programming language version 1.5.4 book - Part 48 of 185Mahmoud Samir Fayed
This chapter discusses creating a game engine for 2D games in Ring. The project has several layers: a games layer that uses declarative programming to create games, game engine classes that use object-oriented programming, an interface layer that hides the details of the graphics libraries, and graphics library bindings that were created using procedural programming. The game engine includes classes like Game, Sprite, Text, and Sound that can be used to easily create 2D games. Examples are provided of simple games created using the engine.
Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, and 2D video frame buffer - a core component of the PDK.
SDL2 Game Development VT Code Camp 2013Eric Basile
This document provides an overview of the Simple DirectMedia Layer (SDL) library for 2D game development. It introduces SDL, its history and creators, how it provides cross-platform access to graphics, audio, input, and more. It covers initializing SDL, creating windows and renderers, basic event handling, 2D drawing, loading images and sounds, and the basic structure of an SDL game loop. Extensions like SDL_image and SDL_mixer are discussed. Sample code demonstrates common SDL tasks.
Cross-platform game engine development with SDL 2.0Leszek Godlewski
Lecture from the WGK 2013 game development conference
The SDL library (Simple DirectMedia Layer) - known as "the open source response to DirectX" - lets you forget about all the boilerplate in game development on platforms ranging from Windows, through Linux and Mac OS X, to iOS and Android. While still in active development, version 2.0 of SDL provides new and improved functionality, including touch input and force feedback support. It also ships with the Steam Linux Library. This lecture provides an overview of the library's capabilities and some useful tricks.
XNA is a framework for creating 2D and 3D games for Windows Phone 7. It includes tools for game development and resource management. The XNA framework provides classes to create gameplay and manage game resources like textures, models, and scripts. When an XNA game runs, it loads resources at start up, then repeatedly updates the game world based on input and draws the updated world. The core methods that drive this cycle are LoadContent, Update, and Draw. LoadContent loads resources. Update handles game logic and state changes. Draw renders the current game state to the screen.
This document provides an overview of using the XNA framework to create games for Windows Phone 7. It discusses that XNA is a framework for writing 2D and 3D games. It includes tools for game production and resource management. The document explains how to load game assets, create sprites, and use the XNA game class methods like LoadContent, Update, and Draw to initialize resources, update the game world, and draw to the screen. It provides an example of creating a simple game that draws a texture and moves it by updating its rectangle position in the Update method.
The Ring programming language version 1.5.2 book - Part 47 of 181Mahmoud Samir Fayed
This document describes a game engine project that uses multiple programming paradigms. The project has four layers: 1) a games layer that uses declarative programming to create games, 2) game engine classes that use object-oriented programming, 3) an interface layer that hides graphics library details using procedural programming, and 4) graphics library bindings implemented in C. The document provides details on the classes and functions available in each layer. It also outlines some example games that can be built with the engine.
This document provides an overview of using the libGDX framework to implement a simple 2D game in Java. It discusses topics such as setting up the starter class, loading assets like images and audio, rendering with an orthographic camera, sprite batch for drawing textures, handling input, collision detection using rectangles, and more. The goal is to demonstrate the basic building blocks for creating a 2D game with libGDX.
Introduction to Game Programming: Using C# and Unity 3D - Chapter 6 (Preview)noorcon
The document provides background information on the origins and history of the board game Battleship. It describes how the game was first played in World War I as a French game called L'Attaque. Early commercial versions of the game were published in the 1930s-1940s. It also notes that Battleship was one of the earliest computer games, released for the Z80 Compucolor in 1979. The document then outlines the basic rules and gameplay of Battleship, describing how players take turns calling out grid coordinates to try and sink their opponent's ships.
Introduction to Game Programming: Using C# and Unity 3D - Chapter 3 (Preview)noorcon
This document provides an overview of key Unity concepts:
- GameObjects are containers that hold Components, which define an object's appearance and behavior. Common Components include Transform, Mesh Filter, and Renderer.
- Tags and layers help categorize GameObjects. The Transform defines an object's position, rotation, and scale.
- Scripts function as custom Components when attached to GameObjects. Components have properties that can be edited in the Inspector.
- Parent-child relationships cause child objects to inherit a parent's transformations, allowing complex hierarchies. Prefabs allow instantiating template GameObjects.
Cocos2d-x C++ Windows 8 &Windows Phone 8Troy Miles
In the first of two sessions, we will explore using Cocos2d-x, a free and open source game engine. It runs on Windows, Mac OS X, and Linux and builds games for every popular phone, tablet, and desktop platform. It uses C++ to get close to metal performance and a smart and logical set of classes to make it easy.
Don't let the C++ scare you off. We are using Cocos2d-x to create fun platform games, not building complicated financial software. So long as you know at least one curly brace language you will be able to write Cocos2d-x style C++.
We will explore how to install Cocos2d-x. How to build the test apps and finally how to build your own apps specifically for Windows 8 and Windows Phone 8, but the code will run on iOS, Mac, and Android too.
Game development with Cocos2d-x EngineDuy Tan Geek
This document discusses using the Cocos2d-x game engine for mobile game development. It provides an overview of Cocos2d-x, describing its cross-platform capabilities, open source nature, and modules for graphics, animation, audio, GUI, physics and more. Key classes in Cocos2d-x like Scene, Layer, Sprite, Node and Actions are explained.
1. The document discusses various aspects of user input and frame animation in libGDX, including touch input, keyboard input, gestures, the accelerometer, and sprite animation.
2. It explains how to set up input processing using InputProcessor and GestureDetector, and how to read touch, keyboard, and accelerometer values.
3. It also provides examples of creating sprite animations by splitting textures into frames and using the Animation class.
Introduction to Game Programming: Using C# and Unity 3D - Chapter 2 (Preview)noorcon
The reader is introduced to the Unity 3D IDE. The basic sections of the IDE are defined and explained. The reader is show how to navigate within the IDE and create GameObjects. How to perform transformations and etc… The Inspector Window is also discussed.
The document discusses LibGDX's support for internationalization and scene 2D.
It describes how to create property files for different languages to support internationalization in LibGDX games. It then provides an overview of Scene2D, describing it as an optional higher-level framework for creating 2D games and UIs using stages, actors, and events. It includes code examples of creating a stage and adding an actor, as well as handling input events with actors.
The Ring programming language version 1.6 book - Part 50 of 189Mahmoud Samir Fayed
This chapter discusses creating a game engine for 2D games in Ring using different programming paradigms. The project has layers for the games, game engine classes, interface to graphics libraries, and graphics library bindings. The graphics library bindings allow using Allegro and SDL through similar functions. The interface layer hides library details. The game engine classes like Game, Sprite, etc. are designed for declarative programming. Games are created by declaring objects from these classes.
The Ring programming language version 1.9 book - Part 80 of 210Mahmoud Samir Fayed
The document discusses Ring documentation and provides examples of using Qt classes and events in Ring. It includes:
1) A table listing Qt classes and their associated methods for using default events, such as QPushButton's setClickEvent() and QTimer's setTimeoutEvent().
2) An example of a cards game application developed in Ring using Qt classes like QPushButton, QPixmap, and QTimer. The game displays cards, tracks scores, and declares functions for game logic and events.
3) Screenshots of the cards game running on desktop and mobile that demonstrate gameplay and event handling during runtime.
WebGL and COLLADA were discussed as technologies for 3D rendering and asset interchange on the web. The presentation covered the history and capabilities of both standards. It also described approaches for loading COLLADA assets into WebGL, such as preprocessing COLLADA into JSON or loading XML directly and parsing it with JavaScript. Optimizing COLLADA assets for WebGL rendering through techniques like quantization and compression was also mentioned.
This document discusses user input handling in libGDX, including event vs polling, touch and keyboard input, accelerometer input, gestures, and text input. It provides code examples for setting up input processors and listeners to handle different types of input in libGDX, including touch, keyboard, accelerometer, and gesture events. It also covers vibration and compass input.
This document discusses Box2D, a 2D physics engine, and how it can be used with libGDX, an open-source game development framework. It provides an overview of Box2D concepts like the world, bodies, fixtures, shapes, and joints. It also discusses how to set up a Box2D world in libGDX, create dynamic and static bodies, add fixtures to bodies, and render physics simulations. The document includes code examples for creating a Box2D world, bodies, and handling the physics step to update simulations over time.
Cross-scene references: A shock to the system - Unite Copenhagen 2019Unity Technologies
Discover the GUID Based reference workflow, with a focus on Multi-Scene workflows, save game, and how these all came together in System Shock 3. You'll learn about the reason for wanting a stable instance Id, why Unity doesn't have one out of the box, what this implementation does, and how you can use it in your own projects. System Shock 3 is a great example of this tool's power, but demonstrates how it can be tricky too.
Speaker:
William Armstrong - Unity
This document discusses graphics and game development in Java ME. It covers the class hierarchy for graphics elements, using the Canvas class to draw graphics, handling events, and using the Game API including the GameCanvas class, layers, sprites and animation. Key topics include drawing with the Graphics object, coordinates, repainting, handling input events, implementing a game loop to control frame rate, and using the LayerManager and Sprite classes to implement layers and sprite animation.
The Ring programming language version 1.7 book - Part 53 of 196Mahmoud Samir Fayed
This document provides documentation on Ring's game engine and graphics libraries. It describes:
1) The gl_allegro and gl_libsdl libraries that provide a common interface to Allegro and SDL graphics libraries to allow switching between them.
2) The main classes in the game engine like Game, GameObject, Sprite, Text, Animate, Sound and Map that can be used to build games.
3) How to use the game engine classes through declarative programming to create games, including examples showing text, sound, animation and functions.
- Tiled is an open-source editor for creating and editing tile maps for use in video games and other multimedia projects.
- LibGDX is a cross-platform game development framework that supports loading and rendering Tiled maps.
- Tiled maps can have multiple layers, tiles, and object layers for entities like the player.
- LibGDX provides classes for loading, rendering, and getting tile map data from Tiled maps to enable map navigation and collision detection in games.
The Ring programming language version 1.4.1 book - Part 19 of 31Mahmoud Samir Fayed
The document provides documentation on RingQt classes and their methods for handling events. It includes:
1. A table listing common RingQt classes and their methods for using default events, such as setClickEvent() for QPushButton.
2. Details on the QAllEvents class for handling events filtering, including its methods for getting event parameters.
3. A comparison of some differences between Qt and RingQt methods and class names to avoid conflicts with Ring keywords.
4. A note that the RingQt Classes and Methods Reference chapter provides more details on supported classes and methods.
5. An explanation that new classes were added where indexes start from 1 when dealing with GUI controls, for consistency with Ring.
The document discusses framerate independence in games using libGDX. It explains that using delta time ensures games run at the same speed regardless of framerate. It provides an example of moving an object at a constant speed of 1 pixel per frame by multiplying the object's speed by delta time. The document also covers creating and rendering animations in libGDX using the Animation class and TextureRegions. It provides tips on extending the Sprite class to create customized sprite objects and animate them by calling animate() each frame.
This document discusses system modeling using the Unified Modeling Language (UML). It introduces UML, explaining that UML allows modeling of systems with an object-oriented perspective using various diagram types. It focuses on UML use case diagrams, class diagrams, and object diagrams. It provides examples of how to construct and interpret these diagram types to model systems, classes, objects, and their relationships.
Introduction to Game Programming: Using C# and Unity 3D - Chapter 6 (Preview)noorcon
The document provides background information on the origins and history of the board game Battleship. It describes how the game was first played in World War I as a French game called L'Attaque. Early commercial versions of the game were published in the 1930s-1940s. It also notes that Battleship was one of the earliest computer games, released for the Z80 Compucolor in 1979. The document then outlines the basic rules and gameplay of Battleship, describing how players take turns calling out grid coordinates to try and sink their opponent's ships.
Introduction to Game Programming: Using C# and Unity 3D - Chapter 3 (Preview)noorcon
This document provides an overview of key Unity concepts:
- GameObjects are containers that hold Components, which define an object's appearance and behavior. Common Components include Transform, Mesh Filter, and Renderer.
- Tags and layers help categorize GameObjects. The Transform defines an object's position, rotation, and scale.
- Scripts function as custom Components when attached to GameObjects. Components have properties that can be edited in the Inspector.
- Parent-child relationships cause child objects to inherit a parent's transformations, allowing complex hierarchies. Prefabs allow instantiating template GameObjects.
Cocos2d-x C++ Windows 8 &Windows Phone 8Troy Miles
In the first of two sessions, we will explore using Cocos2d-x, a free and open source game engine. It runs on Windows, Mac OS X, and Linux and builds games for every popular phone, tablet, and desktop platform. It uses C++ to get close to metal performance and a smart and logical set of classes to make it easy.
Don't let the C++ scare you off. We are using Cocos2d-x to create fun platform games, not building complicated financial software. So long as you know at least one curly brace language you will be able to write Cocos2d-x style C++.
We will explore how to install Cocos2d-x. How to build the test apps and finally how to build your own apps specifically for Windows 8 and Windows Phone 8, but the code will run on iOS, Mac, and Android too.
Game development with Cocos2d-x EngineDuy Tan Geek
This document discusses using the Cocos2d-x game engine for mobile game development. It provides an overview of Cocos2d-x, describing its cross-platform capabilities, open source nature, and modules for graphics, animation, audio, GUI, physics and more. Key classes in Cocos2d-x like Scene, Layer, Sprite, Node and Actions are explained.
1. The document discusses various aspects of user input and frame animation in libGDX, including touch input, keyboard input, gestures, the accelerometer, and sprite animation.
2. It explains how to set up input processing using InputProcessor and GestureDetector, and how to read touch, keyboard, and accelerometer values.
3. It also provides examples of creating sprite animations by splitting textures into frames and using the Animation class.
Introduction to Game Programming: Using C# and Unity 3D - Chapter 2 (Preview)noorcon
The reader is introduced to the Unity 3D IDE. The basic sections of the IDE are defined and explained. The reader is show how to navigate within the IDE and create GameObjects. How to perform transformations and etc… The Inspector Window is also discussed.
The document discusses LibGDX's support for internationalization and scene 2D.
It describes how to create property files for different languages to support internationalization in LibGDX games. It then provides an overview of Scene2D, describing it as an optional higher-level framework for creating 2D games and UIs using stages, actors, and events. It includes code examples of creating a stage and adding an actor, as well as handling input events with actors.
The Ring programming language version 1.6 book - Part 50 of 189Mahmoud Samir Fayed
This chapter discusses creating a game engine for 2D games in Ring using different programming paradigms. The project has layers for the games, game engine classes, interface to graphics libraries, and graphics library bindings. The graphics library bindings allow using Allegro and SDL through similar functions. The interface layer hides library details. The game engine classes like Game, Sprite, etc. are designed for declarative programming. Games are created by declaring objects from these classes.
The Ring programming language version 1.9 book - Part 80 of 210Mahmoud Samir Fayed
The document discusses Ring documentation and provides examples of using Qt classes and events in Ring. It includes:
1) A table listing Qt classes and their associated methods for using default events, such as QPushButton's setClickEvent() and QTimer's setTimeoutEvent().
2) An example of a cards game application developed in Ring using Qt classes like QPushButton, QPixmap, and QTimer. The game displays cards, tracks scores, and declares functions for game logic and events.
3) Screenshots of the cards game running on desktop and mobile that demonstrate gameplay and event handling during runtime.
WebGL and COLLADA were discussed as technologies for 3D rendering and asset interchange on the web. The presentation covered the history and capabilities of both standards. It also described approaches for loading COLLADA assets into WebGL, such as preprocessing COLLADA into JSON or loading XML directly and parsing it with JavaScript. Optimizing COLLADA assets for WebGL rendering through techniques like quantization and compression was also mentioned.
This document discusses user input handling in libGDX, including event vs polling, touch and keyboard input, accelerometer input, gestures, and text input. It provides code examples for setting up input processors and listeners to handle different types of input in libGDX, including touch, keyboard, accelerometer, and gesture events. It also covers vibration and compass input.
This document discusses Box2D, a 2D physics engine, and how it can be used with libGDX, an open-source game development framework. It provides an overview of Box2D concepts like the world, bodies, fixtures, shapes, and joints. It also discusses how to set up a Box2D world in libGDX, create dynamic and static bodies, add fixtures to bodies, and render physics simulations. The document includes code examples for creating a Box2D world, bodies, and handling the physics step to update simulations over time.
Cross-scene references: A shock to the system - Unite Copenhagen 2019Unity Technologies
Discover the GUID Based reference workflow, with a focus on Multi-Scene workflows, save game, and how these all came together in System Shock 3. You'll learn about the reason for wanting a stable instance Id, why Unity doesn't have one out of the box, what this implementation does, and how you can use it in your own projects. System Shock 3 is a great example of this tool's power, but demonstrates how it can be tricky too.
Speaker:
William Armstrong - Unity
This document discusses graphics and game development in Java ME. It covers the class hierarchy for graphics elements, using the Canvas class to draw graphics, handling events, and using the Game API including the GameCanvas class, layers, sprites and animation. Key topics include drawing with the Graphics object, coordinates, repainting, handling input events, implementing a game loop to control frame rate, and using the LayerManager and Sprite classes to implement layers and sprite animation.
The Ring programming language version 1.7 book - Part 53 of 196Mahmoud Samir Fayed
This document provides documentation on Ring's game engine and graphics libraries. It describes:
1) The gl_allegro and gl_libsdl libraries that provide a common interface to Allegro and SDL graphics libraries to allow switching between them.
2) The main classes in the game engine like Game, GameObject, Sprite, Text, Animate, Sound and Map that can be used to build games.
3) How to use the game engine classes through declarative programming to create games, including examples showing text, sound, animation and functions.
- Tiled is an open-source editor for creating and editing tile maps for use in video games and other multimedia projects.
- LibGDX is a cross-platform game development framework that supports loading and rendering Tiled maps.
- Tiled maps can have multiple layers, tiles, and object layers for entities like the player.
- LibGDX provides classes for loading, rendering, and getting tile map data from Tiled maps to enable map navigation and collision detection in games.
The Ring programming language version 1.4.1 book - Part 19 of 31Mahmoud Samir Fayed
The document provides documentation on RingQt classes and their methods for handling events. It includes:
1. A table listing common RingQt classes and their methods for using default events, such as setClickEvent() for QPushButton.
2. Details on the QAllEvents class for handling events filtering, including its methods for getting event parameters.
3. A comparison of some differences between Qt and RingQt methods and class names to avoid conflicts with Ring keywords.
4. A note that the RingQt Classes and Methods Reference chapter provides more details on supported classes and methods.
5. An explanation that new classes were added where indexes start from 1 when dealing with GUI controls, for consistency with Ring.
The document discusses framerate independence in games using libGDX. It explains that using delta time ensures games run at the same speed regardless of framerate. It provides an example of moving an object at a constant speed of 1 pixel per frame by multiplying the object's speed by delta time. The document also covers creating and rendering animations in libGDX using the Animation class and TextureRegions. It provides tips on extending the Sprite class to create customized sprite objects and animate them by calling animate() each frame.
This document discusses system modeling using the Unified Modeling Language (UML). It introduces UML, explaining that UML allows modeling of systems with an object-oriented perspective using various diagram types. It focuses on UML use case diagrams, class diagrams, and object diagrams. It provides examples of how to construct and interpret these diagram types to model systems, classes, objects, and their relationships.
This document provides an introduction to game programming using C++ and the Simple DirectMedia Layer (SDL) library. It outlines the basic structure and modules of video games, including the fundamental game loop of input, update, and output. It then explains how to set up an SDL project in Xcode, implement the basic game loop, and use SDL functions to initialize graphics, handle input events, and display output. The goal is to familiarize students with building the core framework of a video game using industry standard tools and techniques.
This chapter discusses object-oriented programming concepts including constructors, destructors, composition, inheritance, exception handling, and the advantages of OOP. Constructors establish objects while destructors destroy them. Composition involves one class containing objects of another class. Inheritance allows applying knowledge of a general class to more specific subclasses. Exception handling is used to gracefully handle errors in OOP. Overall, OOP aims to save development time through reuse, inheritance, and polymorphism.
This chapter discusses file handling and applications in programming logic and design. It covers topics such as computer files, the data hierarchy, performing file operations like reading, writing and sorting, control break logic for grouping data, merging files, master and transaction file processing, and random access files. The chapter includes objectives, explanations of key concepts, examples, and figures to illustrate file processing techniques.
This chapter discusses relational databases and database design. It covers topics such as database fundamentals, creating tables, primary keys, relationships between tables, anomalies and normalization. The goal is to learn how to structure data to reduce redundancy and avoid problems. Specific techniques covered include first normal form to eliminate repeating groups, and second normal form to eliminate partial dependencies.
This document provides an overview of game design concepts and principles. It discusses the different stages of creating a game, including concept, structure, and design. Game elements like style, plot, character, setting, and theme are explained. Various genres are identified and tips are provided for developing ideas, criticizing concepts, and determining feasibility. The creative process of inspiration, synthesis, resonance and convergence is outlined. Finally, components of an effective game design document are reviewed.
This chapter discusses loops and their advantages. Loops make programming more efficient by allowing a set of instructions to be repeated for multiple data sets with less coding, fewer errors, and shorter compile times. The chapter covers definite and indefinite loops using counters and sentinel values, nested loops, common mistakes to avoid in loops, and applications of loops like accumulating totals and validating data.
Introduction to HTML5 game development (with Phaser)Valerio Riva
This document provides an introduction to HTML5 game development using the Phaser framework. It discusses key concepts like sprites, tilemaps, collisions, and input handling. It also covers Phaser game states, deployment options, and includes an example of building a basic game with Phaser.
Skills You Need to Be a Video Game DeveloperMSBCollege
Want to go from playing video games to creating them yourself? This post from Minnesota School of Business runs down some of the skills you'll need to become a video game developer.
This chapter discusses event-driven GUI programming, multithreading, and animation. It covers the principles of event-driven programming, user-initiated actions and GUI components, designing graphical user interfaces, developing an event-driven application, threads and multithreading, and creating animation. The document provides details on each topic, including examples and figures to illustrate key concepts.
This document provides an introduction to game design and development. It defines what a game is, including plays, sports, video games and computer games. It then discusses game design theory, including primary schemas related to rules, play and culture. It also covers game fundamentals and components. The document outlines the evolution of graphics, sound, controllers, technology and multiplayer aspects of games. Finally, it discusses various game genres such as adventure, board/card, puzzle, platform, strategy, sport, action, shooting, simulation, role-playing, music/dance and cross genres games.
Video game design and programming course for the Master in Computer Engineering at the Politecnico di Milano. http://www.facebook.com/polimigamecollective https://twitter.com/@POLIMIGC http://www.youtube.com/PierLucaLanzi http://www.polimigamecollective.org
Politecnico di Milano, Videogiochi, Video Games, Computer Engineering, game design, game development, sviluppo videogiochi
Videogame Design and Programming - 08 The Design DocumentPier Luca Lanzi
Lecture for the Videogame Design and Programming course for the MSc Engineering of Computing Systems (Laurea Magistrale in Ingegneria Informatica) - Politecnico di Milano.
Prof. Pier Luca Lanzi
Dipartimento di Elettronica, Informazione, e Bioingegneria
Course Webpage:
http://www.polimigamecollective.org
Course Facebook Page:
https://www.facebook.com/polimigamecollective
Introduzione alla realizzazione di videogiochi - Game EnginePier Luca Lanzi
Slide del corso "Introduzione alla realizzazione di videogiochi" tenuto per gli studenti delle scuole superiori presso la sede di Cremona del Politecnico di Milano.
This document provides an overview of game development including defining video games, common genres, the size of the industry, and the development process from concept to release. It also outlines the major roles in game development such as designers, artists, programmers, testers, and producers. Finally, it discusses skills required for different roles and ways to get started in the industry such as through independent game development.
BGE is an open-source C++ game engine framework for teaching component-based game development. It uses OpenGL for 3D graphics rendering and libraries like GLEW, GLM, SDL, Bullet and FMOD. Everything in BGE is a component that extends the base GameComponent class. GameComponents can have children components and update/draw in a hierarchy. This allows reusable and flexible game object creation through composition of components rather than inheritance.
The document provides an introduction to 2D game development with Unity. It discusses key Unity concepts such as scenes, game objects, components and scripts. It then demonstrates how to build a basic 2D platformer game in Unity, including creating a player character, allowing movement with scripts, adding animations, developing platforms, and enabling jumping. The document recommends resources for further learning Unity and 2D game development.
Scene Graphs & Component Based Game EnginesBryan Duggan
A presentation I made at the Fermented Poly meetup in Dublin about Scene Graphs & Component Based Game Engines. Lots of examples from my own game engine BGE - where almost everything is a component. Get the code and the course notes here: https://github.com/skooter500/BGE
Developing for Plone using ArchGenXML / ArgoUMLJazkarta, Inc.
July 24, 2006. The training materials for the Plone Magic Camp in Brooklyn, NY. This day-long course helps you get started with rapid application development using ArchGenXML and ArgoUML. We walk through an example of building an Artist and Group classes in ArgoUML, and auto-generate the Plone product code using ArchGenXML.
The document discusses several JavaScript libraries that can be used to build HTML5 and JavaScript games. It describes EaselJS, which makes working with the HTML5 Canvas element easier, TweenJS for tweening and animating properties, SoundJS for working with audio, and PreloadJS for managing asset loading. It also briefly mentions CreateJS, which is a suite that includes these libraries and allows building rich interactive content for the open web using HTML5.
The Ring programming language version 1.5.3 book - Part 48 of 184Mahmoud Samir Fayed
This document provides documentation on creating a 2D game engine in Ring. It discusses organizing the project into layers, including the games layer, game engine classes layer, and interface to graphics library layer. It then describes the key classes in the game engine - Game, GameObject, Sprite, Text, Animate, Sound, and Map. It provides details on the attributes and methods for each class. It also provides an example of how to load the game engine library, create a Game object, and start drawing text to the screen. The document is intended to teach how to structure a 2D game engine project using different programming paradigms in Ring.
The Ring programming language version 1.5.3 book - Part 58 of 184Mahmoud Samir Fayed
This document provides an overview of how to build a 2D game engine in Ring using different programming paradigms. It discusses using declarative programming for the game layer, object-oriented programming for game engine classes, and procedural programming for the graphics library interface. The document outlines the layers of the engine including graphics library bindings, the interface layer, game engine classes, and the games layer. It provides details on key classes like Game, GameObject, Sprite, Text, Animate, Sound, and Map that can be used to build games. Examples are given for creating a game window and drawing/animating text to demonstrate using the engine.
This document provides an overview of developing a Silverlight game, including designing levels and storyboards, implementing game logic for player movement and collision detection, developing the game using tools like Visual Studio and Expression Blend, and organizing code using the MVC pattern. It also describes techniques for animating game elements like scrolling the game board and frame-by-frame animations, as well as managing sounds. The game is divided into modular XAP files that are downloaded and loaded dynamically.
The document discusses computer graphics and the OpenGL rendering process. It describes the graphics pipeline which processes vertex data through various shader stages before fragments are rendered to the screen. These stages include vertex shading, tessellation, geometry processing, clipping, and fragment shading. OpenGL is introduced as a cross-platform graphics API that utilizes these shader programs to leverage the parallel processing capabilities of GPUs. Basic concepts like buffers, shaders, and drawing objects are also covered.
The Ring programming language version 1.2 book - Part 36 of 84Mahmoud Samir Fayed
The document describes a game engine for 2D games created using Ring. It has the following layers:
1) Games layer uses declarative programming to create games.
2) Game engine classes layer uses object-oriented programming for classes like Game, Sprite, etc.
3) Interface layer hides differences between graphics libraries (Allegro, SDL) for a consistent API.
4) Graphics library bindings generate C code from configuration files to interface with Allegro and SDL.
The engine provides classes for games, objects, sprites, text, animation and sound. Examples show creating a game window, drawing text, playing sounds, and animating sprites. The engine handles input and updating the game loop.
This document provides an introduction to developing video games across multiple platforms using Unity3D and C#. It outlines downloading and installing Unity3D, exploring the Unity interface, developing games on PC and Mac, using scenes, game objects, components and scripts in Unity, and deploying games to PC, Mac, mobile, and web platforms. It also discusses additional tools that can be used and provides an overview of building a sample voxel engine game in Unity3D to demonstrate core concepts.
This document provides an overview of Cocos2D, an open source framework for building 2D games and other interactive applications. It discusses Cocos2D's scene graph structure, principal classes like CCNode and CCDirector, use of sprites and actions, and tools for working with Cocos2D like TexturePacker. It also compares building games with Cocos2D on iOS versus Android and introduces Cocos2D-X for cross-platform development and Cocos2D-HTML5 for web games.
This document discusses using the Rokon game engine for Android game development. It provides an overview of Rokon's architecture and frameworks, describes how to set up an Android project in Netbeans using Rokon, and covers basics of using Rokon and the Smack XMPP library for multiplayer functionality. Tips are provided on tool choices and ongoing development of Rokon. Links are included for the Android SDK, Rokon engine, Smack library, and other resources.
This document provides an overview and development plan for creating a basic Pong game. It discusses focusing on core mechanics like controls, gameplay, and programming. The plan involves iteratively developing features starting with basic elements like drawing the court and balls, then adding player input and ball collisions. It emphasizes taking an iterative approach, with development occurring in small steps that can be completed in a single sitting to allow for consistent progress. The document also provides guidance on object-oriented programming principles, memory management, and structuring the game controller class to manage the game loop and different game states.
GamePlay3D is an open-source 3D game framework that supports development for numerous platforms using C++. It aims to provide developers with a flexible, simple, and intuitive API for building cross-platform 3D games. Key features include a declarative approach using text files, support for 3D graphics using OpenGL, a physics engine, GUI system, asset management, and Lua scripting.
Python tools to deploy your machine learning models fasterJeff Hale
Comparing Gradio, Streamlit, and FastAPI (with a little discussion of flask)
Jeff Hale's presentation for Data Science DC March 8, 2022
Repository with code at https://github.com/discdiver/dsdc-deploy-models
The document describes a graphics editor program that simulates the MS Paint application. It uses OpenGL for graphics rendering and GLUT for creating windows and rendering scenes. Key features implemented include tools for drawing shapes, images, and text. OpenGL functions are used for rendering while GLUT functions handle window creation and events. The design section covers header files, OpenGL/GLUT functions, and user-defined functions for tasks like drawing, erasing, and filling shapes. Implementation details are provided for various drawing algorithms and user interface elements.
This document provides a programmers guide for Cocos2d-x version 3.3. It includes chapters on basic Cocos2d-x concepts such as scenes, nodes, sprites, actions, and the scene graph. The guide explains how to create and manipulate sprites, run actions and sequences of actions, and handle parent-child relationships between nodes. It aims to teach programmers how to use Cocos2d-x to develop cross-platform 2D games.
The simplified electron and muon model, Oscillating Spacetime: The Foundation...RitikBhardwaj56
Discover the Simplified Electron and Muon Model: A New Wave-Based Approach to Understanding Particles delves into a groundbreaking theory that presents electrons and muons as rotating soliton waves within oscillating spacetime. Geared towards students, researchers, and science buffs, this book breaks down complex ideas into simple explanations. It covers topics such as electron waves, temporal dynamics, and the implications of this model on particle physics. With clear illustrations and easy-to-follow explanations, readers will gain a new outlook on the universe's fundamental nature.
How to Add Chatter in the odoo 17 ERP ModuleCeline George
In Odoo, the chatter is like a chat tool that helps you work together on records. You can leave notes and track things, making it easier to talk with your team and partners. Inside chatter, all communication history, activity, and changes will be displayed.
Main Java[All of the Base Concepts}.docxadhitya5119
This is part 1 of my Java Learning Journey. This Contains Custom methods, classes, constructors, packages, multithreading , try- catch block, finally block and more.
This presentation includes basic of PCOS their pathology and treatment and also Ayurveda correlation of PCOS and Ayurvedic line of treatment mentioned in classics.
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPRAHUL
This Dissertation explores the particular circumstances of Mirzapur, a region located in the
core of India. Mirzapur, with its varied terrains and abundant biodiversity, offers an optimal
environment for investigating the changes in vegetation cover dynamics. Our study utilizes
advanced technologies such as GIS (Geographic Information Systems) and Remote sensing to
analyze the transformations that have taken place over the course of a decade.
The complex relationship between human activities and the environment has been the focus
of extensive research and worry. As the global community grapples with swift urbanization,
population expansion, and economic progress, the effects on natural ecosystems are becoming
more evident. A crucial element of this impact is the alteration of vegetation cover, which plays a
significant role in maintaining the ecological equilibrium of our planet.Land serves as the foundation for all human activities and provides the necessary materials for
these activities. As the most crucial natural resource, its utilization by humans results in different
'Land uses,' which are determined by both human activities and the physical characteristics of the
land.
The utilization of land is impacted by human needs and environmental factors. In countries
like India, rapid population growth and the emphasis on extensive resource exploitation can lead
to significant land degradation, adversely affecting the region's land cover.
Therefore, human intervention has significantly influenced land use patterns over many
centuries, evolving its structure over time and space. In the present era, these changes have
accelerated due to factors such as agriculture and urbanization. Information regarding land use and
cover is essential for various planning and management tasks related to the Earth's surface,
providing crucial environmental data for scientific, resource management, policy purposes, and
diverse human activities.
Accurate understanding of land use and cover is imperative for the development planning
of any area. Consequently, a wide range of professionals, including earth system scientists, land
and water managers, and urban planners, are interested in obtaining data on land use and cover
changes, conversion trends, and other related patterns. The spatial dimensions of land use and
cover support policymakers and scientists in making well-informed decisions, as alterations in
these patterns indicate shifts in economic and social conditions. Monitoring such changes with the
help of Advanced technologies like Remote Sensing and Geographic Information Systems is
crucial for coordinated efforts across different administrative levels. Advanced technologies like
Remote Sensing and Geographic Information Systems
9
Changes in vegetation cover refer to variations in the distribution, composition, and overall
structure of plant communities across different temporal and spatial scales. These changes can
occur natural.
Executive Directors Chat Leveraging AI for Diversity, Equity, and InclusionTechSoup
Let’s explore the intersection of technology and equity in the final session of our DEI series. Discover how AI tools, like ChatGPT, can be used to support and enhance your nonprofit's DEI initiatives. Participants will gain insights into practical AI applications and get tips for leveraging technology to advance their DEI goals.
Walmart Business+ and Spark Good for Nonprofits.pdfTechSoup
"Learn about all the ways Walmart supports nonprofit organizations.
You will hear from Liz Willett, the Head of Nonprofits, and hear about what Walmart is doing to help nonprofits, including Walmart Business and Spark Good. Walmart Business+ is a new offer for nonprofits that offers discounts and also streamlines nonprofits order and expense tracking, saving time and money.
The webinar may also give some examples on how nonprofits can best leverage Walmart Business+.
The event will cover the following::
Walmart Business + (https://business.walmart.com/plus) is a new shopping experience for nonprofits, schools, and local business customers that connects an exclusive online shopping experience to stores. Benefits include free delivery and shipping, a 'Spend Analytics” feature, special discounts, deals and tax-exempt shopping.
Special TechSoup offer for a free 180 days membership, and up to $150 in discounts on eligible orders.
Spark Good (walmart.com/sparkgood) is a charitable platform that enables nonprofits to receive donations directly from customers and associates.
Answers about how you can do more with Walmart!"
Strategies for Effective Upskilling is a presentation by Chinwendu Peace in a Your Skill Boost Masterclass organisation by the Excellence Foundation for South Sudan on 08th and 09th June 2024 from 1 PM to 3 PM on each day.
2. Purpose
Ê Object-‐Oriented
Programming
approach
on
video
game
development
Ê Automatic
Resource
Management
Ê GD4N
means
Game
Development
for
Noobs
J
3. Set
Up
Ê Create
a
solution
(or
workspace)
called
GD4N_Games.
This
is
where
we’ll
put
our
GD4N
and
the
games
that
depend
on
it.
Ê Create
a
project
in
GD4N_Games,
called
GD4N,
that
builds
a
library
(either
static
or
dynamic).
Ê Link
the
following
libraries
to
GD4N:
Ê SDL,
SDL_image,
SDL_mixer,
SDL_ttf,
OpenGL
Ê Add
the
corresponding
header
&
library
locations
Ê SDL_image
and
SDL_mixer
may
require
additional
libraries,
add
those
accordingly
Ê Build
the
library
which
will
be
linked
by
succeeding
projects
4. Test
Ê Create
an
empty
project
in
GD4N_Games
called
GD4N_Test
Ê Windows:
Win32
Application
Ê Mac
OSX:
Cocoa
Application
Ê Link
the
following
libraries:
Ê GD4N,
SDL,
OpenGL
Ê Add
the
header
locations:
Ê GD4N
Project
folder,
all
SDL
headers
5. Test
Ê Copy
the
files
from
src/GD4N_Test
to
your
project
directory
Ê Load
the
files
into
your
project
Ê Build
and
Run
Ê You
should
see
a
black
800x600
screen
that
can
only
be
closed
by
pressing
the
close
button
Ê If
successful,
create
a
template
based
on
GD4N_Test
7. Design
Paradigms
Ê GD4N
uses
a
list
of
design
paradigms
to
perform
resource
management
and
implement
the
managers
to
be
as
separate
as
possible
Ê It
is
not
necessary
to
fully
understand
these
since
the
point
of
a
framework
is
to
remove
the
necessity
to
know
these
things
but
knowing
these
will
help
you
see
the
game
engine
pieces
clearly
8. Singleton
Design
Pattern
Ê Limit
the
instance
of
a
class
to
only
one,
hence
SINGLEton
Ê The
Singleton
is
created
upon
first
use
(lazy
initialization)
and
is
destroyed
when
the
program
ends
Ê Usually
used
to
represent
Managers
and
Devices
9. (Simplified)
Object
Pool
Ê A
dynamic
container
that
stores
objects
Ê Adding
and
Removing
instances
are
facilitated
by
the
pool
Ê Note:
Ideally,
an
object
pool
prevents
the
overhead
of
new
and
delete
operators
by
re-‐initializing
and
shutting
down
instances.
The
client
simply
requests
for
an
instance
and
the
object
pool
gives
a
pre-‐allocated
resource
(if
available).
10. Template
Method
Pattern
Ê Define
a
set
of
methods
to
be
overridden
by
its
children
Ê The
parent
class
is
intended
to
be
abstract
Ê Not
all
the
methods
need
to
be
overridden
12. constants.h
Ê Each
project
should
have
a
constants.h
which
will
contain
all
the
unique
IDs
pertaining
to
the
different
resources.
Each
resource
to
be
used
should
have
a
corresponding
ID.
13. CSurface
Ê Wraps
around
SDL_Surface
Ê To
load
an
image
Ê CSurface::Load(imagepath,
id)
where
imagepath
is
the
path
to
the
image
and
id
is
a
unique
identifier
Ê Drawing
the
image
is
in
the
SVideoManager
Ê See
the
CSurface.h
for
more
information
14. CSurfaceSheet
Ê A
Surface
Sheet
(or
Sprite
Sheet)
is
an
image
composed
of
equal-‐sized
frames.
Ê In
this
example,
we
have
an
image
composed
of
a
snake
head
looking
at
4
different
directions.
Ê The
image
is
40x40
pixels
with
2
rows
and
2
cols,
making
each
frame
20x20
pixels.
The
maximum
number
of
frames
is
rows
x
cols,
which
is
4
in
this
case.
Ê See
CSurfaceSheet.h
for
more
information
15. CSurfaceSheetAnimated
Ê This
is
the
animated
sprite
sheet.
Inheriting
from
CSurfaceSheet,
this
class
animates
by
going
to
the
next
frame
automatically.
Ê Before
animating,
it
is
important
to
set
the
sprite
dimensions
as
well
as
the
animation
speed
(frames
per
second).
Ê See
CSurfaceSheetAnimated.h
for
more
information
16. CFont
Ê Wraps
around
TTF_Font
(SDL_ttf)
Ê To
load
a
font
Ê CFont::Load(fontpath,
id)
where
fontpath
is
the
path
to
the
true
type
font
and
id
is
a
unique
identifier
Ê To
use
the
font
(create
a
surface
with
text)
Ê CSurface::CreateText(fontId,
text,
textcolor,
id)
where
fontId
is
the
id
of
the
font
to
be
used
and
id
is
the
unique
identifier
to
the
generated
surface.
Ê See
CFont.h
for
more
options
17. CMusic
(background
music)
Ê Wraps
around
Mix_Music
(SDL_mixer)
Ê To
load
music
Ê CMusic::Load(musicpath,
id)
where
musicpath
is
the
path
to
the
audio
file
and
id
is
a
unique
identifier
Ê Playing
music
is
handled
by
the
SAudioManager
Ê See
CMusic.h
for
more
information
18. CChunk
(sound
effects)
Ê Wraps
around
Mix_Chunk
(SDL_mixer)
Ê To
load
a
sound
effect
Ê CChunk::Load(sfxpath,
id)
where
sfxpath
is
the
path
to
the
sound
effect
and
id
is
the
unique
identifier
Ê Player
sound
effects
is
handled
by
the
SAudioManager
Ê See
CChunk.h
for
more
information
20. SInputManager
Ê All
the
input
states
and
events
are
stored
and
updated
through
this
manager
Ê This
manager
handles
multiple
devices
such
as
mouse
and
keyboard
Ê To
access,
use
sInput
21. SVideoManager
Ê Everything
seen
on
the
screen
is
handle
by
this
manager
Ê This
manager
represents
the
video
device
Ê To
access,
use
sVideo
22. SAudioManager
Ê Playing,
pausing,
and
stopping
sound
effects
and
music
tracks
are
handled
by
this
manager
Ê Multiple
sound
effects
can
be
played
simultaneously
Ê Only
1
music
track
can
be
played
at
a
time
Ê To
access,
use
sAudio
23. STimeManager
Ê This
manager
keeps
track
of
the
time
since
the
game
has
started
and
the
number
of
seconds
between
frames
Ê To
access,
use
sTime
25. CGameManager
Ê The
umbrella
class
that
represents
the
game
itself
Ê Special
type
of
Manager
because
it
needs
to
be
inherited
Ê Initializes
and
Shuts
down
all
other
modules
(managers)
Ê Handles
the
changing
of
scenes,
loading
of
resources,
management
of
game
objects
Ê Each
game
should
have
a
class
that
inherits
from
CGameManager
and
overrides
Init()
26. CGameManager
Inherited
Properties
Ê char
*windowTitle;
Ê Defines
the
title
of
the
window
Ê Must
be
changed
before
calling
Init();
Ê char
*icon;
Ê Defines
the
path
to
the
icon
of
the
window
Ê Must
be
changed
before
calling
Init();
27. CGameManager
Overrideable
Methods
Ê bool
Init();
Ê By
default,
this
initializes
SDL
and
GD4N
(must
be
called
in
derived
class)
Ê Register
scenes
Ê Set
SDL
and
GD4N
settings
Ê Determine
initial
scene
Ê void
CleanUp();
Ê By
default,
this
releases
and
shuts
down
SDL
Ê Not
normally
overridden
Ê void
LoadResources();
Ê Loading
of
assets
should
occur
here
28. CGameManager
Utility
Methods
Ê void
StopPlaying();
Ê Public
method
to
shut
down
the
game
Ê void
ChangeScene(int
scene);
Ê Change
scenes
Ê void
AddScene(SceneInit
newScene);
Ê Register
a
scene
to
be
used
by
ChangeScene()
29. CGameManager
Header
Ê There
are
more
methods
at
your
disposal
Ê See
CGameManager.h
for
more
information
31. Game
Object
Ê Everything
that
either
has
logic
or
is
visible
is
a
game
object.
Ê CGameObject
is
the
template
class
for
all
game
objects.
Ê Each
game
object
should
inherit
from
the
CGameObject
class.
The
game
objects
should
override
the
methods
which
are
called
by
the
game
loop.
32. CGameObject
Inherited
Properties
Ê int
id;
Ê A
unique
identifier
generated
when
added
to
the
pool
(handled
by
the
constructor)
Ê Has
a
getter
Ê int
type;
Ê A
type
that
is
game-‐specific
used
for
collisions
(assigned
during
constructor).
The
different
types
are
located
in
constants.h
Ê Has
a
getter
Ê bool
isVisible;
Ê A
flag
to
determine
if
the
object
should
be
draw
or
not
Ê Has
a
getter
and
setter
Ê bool
isActive;
Ê A
flag
to
determine
if
the
object
should
perform
logic
or
not
Ê Has
a
getter
and
setter
33. CGameObject
Overrideable
Methods
Ê void
Draw();
Ê Contains
the
draw
calls
Ê void
DrawGUI();
Ê Contains
the
drawing
of
GUI
calls
Ê void
Update();
Ê Performs
logic
Ê void
CollidesWith(CGameObject
*other);
Ê Performs
logic
upon
collision
Ê bool
IsCollidingWith(CGameObject
*other);
Ê Checks
for
collision
against
another
game
object
36. Game
Specifications
Ê The
game
can
be
played
by
1-‐2
players
Ê Controls
Ê First
player:
arrow
keys
Ê Second
player:
WASD
Ê Eating
the
apple
would
increase
the
consuming
snake’s
length
by
1
Ê Hitting
the
grass
(boundary),
another
snake
or
yourself
would
be
your
doom
37. Getting
Started
Ê Create
a
project,
SnakeGD4N,
based
on
GD4N_Test
Ê Double
check
the
framework,
libraries
and
header
paths!
Ê Rename
CTestGameManager
to
CSnakeGameManager
Ê In
the
h,
cpp
and
main.cpp
Ê Don’t
forget
the
macro
sGameManager!
Ê Copy
the
assets
in
SnakeGD4N-‐00
to
your
working
directory
Ê bkgd
Ê images
Ê sfx
39. Resources
Ê Include
the
following
header
files
into
CSnakeGameManager.cpp
Ê CChunk.h
Ê CMusic.h
Ê CSurface.h
Ê Use
the
namespace
GD4N
globally
Ê In
CSnakeGameManager,
override
LoadResources()
with
the
following
CChunk::Load((char *)"sfx/eat.wav", SFXID_EAT);
sChunkPool->CleanUp();
CMusic::Load((char *)"01-Molly.mp3", MUSICID_01);
sMusicPool->CleanUp();
41. Initialization
Ê Include
the
following
header
files
Ê SVideoManager.h
Ê SAudioManager.h
Ê In
the
constructor,
we
set
the
window
title.
This
can
actually
be
placed
inside
the
Init().
windowTitle = (char *)"Snake!";
Ê Override
the
Init()
and
set
the
video
mode
to
440x400x32
with
flags
SDL_HWSURFACE
|
SDL_DOUBLEBUF.
This
should
be
called
before
the
parent’s
Init()
otherwise,
this
will
have
no
effect.
sVideo->SetVideoMode(440, 440, 32, SDL_HWSURFACE |
SDL_DOUBLEBUF);
Ê Call
the
parent’s
Init()
to
initialize
SDL
and
GD4N
if (!CGameManager::Init()) return false;
Ê When
Init()
goes
well,
return
true
return true;
42. Test!
Ê Build
and
run
the
program
Ê You
should
see
a
black
440x440
window
that
does
nothing
Ê It
is
a
good
practice
to
test
after
every
few
lines
of
code.
Believe
me,
the
benefits
will
go
a
long
way.
Ê See
src/SnakeGD4N-‐01
for
any
clarifications
44. Creating
the
Ground
Ê Let’s
create
our
first
Game
Object!
Let’s
call
it
CGround.
Ê First,
we
create
the
header
file
called
CGround.h
#include "CGameObject.h"
class CGround : public GD4N::CGameObject {
protected:
void Draw();
public:
CGround();
~CGround();
};
45. Creating
the
Ground
Ê Then
the
source
code,
CGround.cpp
#include "CGround.h"
#include "SVideoManager.h"
#include "constants.h"
CGround::CGround() : CGameObject() {
}
CGround::~CGround() {
}
void CGround::Draw() {
sVideo->Draw(SURFID_GROUND);
}
Ê Question:
What
does
the
ground
do?
46. Creating
Scenes
Ê Now
we
have
created
a
game
object,
we
need
to
put
it
in
a
scene
in
the
CSnakeGameManager.
Ê Create
a
method
in
CSnakeGameManager
void CSnakeGameManager::Scene00() {
new CGround();
}
Ê Then
we
register
that
scene
and
load
it
in
Init()
AddScene(CSnakeGameManager::Scene00);
ChangeScene(0);
47. Test!
Ê Build
and
run
the
program.
Ê You
should
see
the
ground
displayed
on
the
screen.
Ê The
Game
Loop
inside
CGameManager
automatically
calls
the
Draw()
method
of
all
the
visible
game
objects
in
the
scene.
Ê See
src/SnakeGD4N-‐02
for
any
clarifications
48. The
Snake
Head
Reacting
to
Input,
Using
the
Time,
Sprite
Sheets
49. Creating
the
Snake
Head
Ê Our
CSnake
game
object
will
react
to
the
arrow
keys,
moving
the
snake
head
accordingly
52. CSnake
Update
and
Draw
void CSnake::Update() {
if (sInput->GetKeyDown(SDLK_RIGHT)) {
position.x++;
} else if (sInput->GetKeyDown(SDLK_LEFT)) {
position.x--;
} else if (sInput->GetKeyDown(SDLK_DOWN)) {
position.y++;
} else if (sInput->GetKeyDown(SDLK_UP)) {
position.y--;
}
}
void CSnake::Draw() {
sVideo->Draw(SURFID_SNAKEHEAD1, position * 20);
}
53. Instantiate
CSnake
Ê Create
an
instance
of
CSnake
in
Scene00
after
CGround
Ê Build
and
run
the
program
and
you
will
see
the
head1.png
displayed
on
the
screen
Ê Moving
the
arrow
keys
would
move
the
snake
head
accordingly
54. Explaining
the
Position
Ê The
position
is
represented
using
2
integers,
x
and
y.
Note
that
our
snake
head
is
actually
an
image
with
width
and
height
equal
to
20
Ê When
the
snake
moves
to
the
right,
it’s
actually
moving
20
pixels
to
the
right
though
it
is
only
incremented
by
1
in
the
Update()
Ê The
factor
of
20
is
applied
in
the
Draw()
method.
Meaning,
our
play
area
(or
screen
dimensions)
is
440x440
but
the
position
values
will
only
range
from
0
to
22.
55. Problems
Ê Things
you
may
have
noticed
1. The
snake
should
be
moving
continuously,
frame-‐independently
2. head1.png
contains
four
snake
heads!
3. No
boundary
conditions!
Ê We
fix
the
first
problem
by
adding
2
variables
for
the
movement
relative
to
time
and
2
variables
for
the
direction
(current
and
next)
Ê For
the
second
problem,
we
use
a
Surface
Sheet
to
represent
the
snake
head
image
in
order
to
draw
the
corresponding
head
depending
on
the
direction
Ê We
will
consider
boundary
conditions
later
on
when
we
go
to
collisions
56. Direction
Type
Ê In
constants.h,
add
the
following
enum
enum direction_t {
DIR_UP = 0,
DIR_DOWN,
DIR_LEFT,
DIR_RIGHT
};
57. More
Snake
Properties
and
Methods
Ê In
CSnake.h,
add
the
following
include
#include "CSurfaceSheet.h"
Ê And
add
the
following
protected
properties
and
methods
void ReactToInput();
void Move();
direction_t dir;
direction_t newDir;
float timeLast; // time since last movement
float timeBetween; // time between movements
GD4N::CSurfaceSheet *headTexture;
58. CSnake()
and
~CSnake()
Ê If
you
looked
at
head1.png,
you
will
notice
that
it’s
a
2x2
sprite
sheet
where
the
first
frame
(upper
left)
is
facing
left
and
the
second
(upper
right)
is
facing
right.
The
third
frame
(lower
left)
is
for
up
and
the
last
frame
is
for
down.
CSnake::CSnake() : CGameObject() {
position.x = 1;
position.y = 1;
newDir = dir = DIR_RIGHT;
timeBetween = 0.1f;
timeLast = -timeBetween;
headTexture = new GD4N::CSurfaceSheet(SURFID_SNAKEHEAD1);
headTexture->SetSpriteDimensions(2, 2);
headTexture->SetCurrentFrame(1);
}
CSnake::~CSnake() {
delete headTexture;
headTexture= 0;
}
59. CSnake::Update()
Ê Update
is
growing
very
big
and
we
need
to
modularize
it
into
2
smaller
functions,
ReactToInput()
and
Move();
Ê The
snake
will
only
move
when
timeBetween
seconds
have
lapsed
void CSnake::Update() {
ReactToInput();
if (timeLast + timeBetween < sTime->GetTime()) {
timeLast = sTime->GetTime();
dir = newDir;
Move();
}
}
60. CSnake::ReactToInput()
and
Draw()
Ê As
a
rule
in
Snake,
if
you’re
moving
to
the
right,
you
can’t
make
a
180
degree
turn
and
face
left.
You
can
only
change
your
direction
to
up
or
down.
Ê dir
is
the
current
direction
while
newDir
is
the
next
direction
void CSnake::ReactToInput() {
if (sInput->GetKeyDown(SDLK_RIGHT) && dir != DIR_LEFT) {
newDir = DIR_RIGHT;
} else if (sInput->GetKeyDown(SDLK_LEFT) && dir != DIR_RIGHT) {
newDir = DIR_LEFT;
} else if (sInput->GetKeyDown(SDLK_DOWN) && dir != DIR_UP) {
newDir = DIR_DOWN;
} else if (sInput->GetKeyDown(SDLK_UP) && dir != DIR_DOWN) {
newDir = DIR_UP;
}
}
void CSnake::Draw() {
sVideo->Draw(headTexture, position * 20);
}
61. CSnake::Move()
Ê When
the
snake
moves,
it
changes
its
position
and
the
frame
to
display
void CSnake::Move() {
switch (dir) {
case DIR_UP:
position.y--;
surface->SetCurrentFrame(2);
break;
case DIR_DOWN:
position.y++;
surface->SetCurrentFrame(3);
break;
case DIR_LEFT:
position.x--;
surface->SetCurrentFrame(0);
break;
case DIR_RIGHT:
position.x++;
surface->SetCurrentFrame(1);
break;
}
}
62. Test!
Ê Build
and
run
the
program!
Ê You
will
see
the
snake
head
moving
in
its
current
direction
unless
it’s
changed
by
pressing
the
arrow
keys
Ê See
src/SnakeGD4N-‐03
for
any
clarifications
64. Body
Movement
Ê The
body
of
the
snake
is
composed
of
segments
Ê Each
segment
follows
the
one
before
it
Ê The
“neck”
is
the
segment
right
before
the
head
Ê The
“tail”
is
the
last
segment
of
the
body
66. CSnakeSegment.cpp
CSnakeSegment::CSnakeSegment() : CGameObject() {
bodyTexture = new GD4N::CSurfaceSheet(SURFID_SNAKEBODY1);
bodyTexture->SetSpriteDimensions(2, 5);
bodyTexture->SetCurrentFrame(0);
}
CSnakeSegment::~CSnakeSegment() {
delete bodyTexture;
bodyTexture = 0;
}
void CSnakeSegment::Draw() {
sVideo->Draw(bodyTexture, position * 20);
}
Ê The
CSnakeSegment
does
not
have
logic.
Notice
that
it’s
only
concerned
with
drawing
itself.
Its
position
property
is
public,
however.
Which
means,
another
game
object
could
simply
change
the
segment’s
position
and
it
will
be
drawn
unto
to
that
new
position.
67. CSnake.h
Ê CSnake
will
handle
the
segments.
Add
the
following
includes
and
protected
properties
#include "CSnakeSegment.h"
#include <vector>
int length;
int desiredLength;
std::vector<CSnakeSegment*> body;
68. CSnake.cpp
Ê Set
the
initial
value
of
length
and
desiredLength
to
0
in
the
constructor.
length = desiredLength = 0;
Ê For
testing
purposes,
we
increase
the
length
of
the
snake
by
pressing
the
space
bar.
Add
the
following
lines
in
ReactToInput()
if (sInput->GetKeyDown(SDLK_SPACE))
desiredLength++;
69. CSnake.cpp
Ê In
the
Move(),
add
the
following
before
the
switch
statement
if (length < desiredLength) {
length++;
body.push_back(new CSnakeSegment());
}
if (length > 0) {
for (int i = length-1; i > 0; i--) {
body[i]->position = body[i-1]->position;
// all segments will copy the one
// before it except for the neck
}
body[0]->position = position;
// neck will copy its position from the head
}
70. Test!
Ê Build
and
run
the
program!
Ê Press
the
space
bar
to
increase
the
length
of
the
snake
Ê See
src/SnakeGD4N-‐04
for
any
clarifications
71. Body
as
Sprite
Sheet
Ê Notice
that
body1.png
is
a
sprite
sheet
with
5
cols
and
2
rows
Ê Currently,
we’re
only
displaying
the
first
frame
(frame
0)
Ê To
display
the
proper
frame
from
our
sprite
sheet,
we
need
to
determine
if
the
segment
is
the
tail
or
not.
Ê If
it’s
the
tail,
we
only
care
what
is
the
direction
of
the
previous
segment
Ê If
it’s
not
the
tail,
determine
if
the
direction
of
the
previous
segment
is
the
same
as
the
current
72. Tail
and
Same
Directions
Tail
Next
Direction
Frame
DIR_UP
2
DIR_DOWN
7
DIR_LEFT
6
DIR_RIGHT
5
Same
Direction
Direction
Frame
DIR_UP
or
DIR_DOWN
1
DIR_LEFT
or
DIR_RIGHT
0
Note:
Frame
indices
start
at
0
73. Different
Directions
(turning)
Ê If
the
direction
of
the
previous
segment
is
different
from
the
direction
of
the
current
segment,
it
must
be
turning
Current
Direction
Next
Direction
Frame
DIR_UP
DIR_RIGHT
3
DIR_LEFT
DIR_DOWN
DIR_RIGHT
DIR_DOWN
4
DIR_UP
DIR_LEFT
DIR_DOWN
DIR_RIGHT
8
DIR_LEFT
DIR_UP
DIR_RIGHT
DIR_UP
9
DIR_DOWN
DIR_LEFT
Note:
Frame
indices
start
at
0
74. CSnakeSegment
Ê Add
the
following
protected
property
and
public
methods
in
the
header
direction_t dir;
direction_t GetDirection() { return dir; }
void SetDirection(direction_t newDir, bool
isTail = false);
Ê Implement
SetDirection()
given
the
tables
in
the
previous
slide.
Remember
to
assign
direction
on
the
given
newDir.
75. CSnake.cpp
Ê In
Move();
a
slight
modification
is
applied
in
order
to
set
the
direction
of
the
segments
(aside
from
the
position)
if (length > 0) {
for (int i = length-1; i > 0; i--) {
// all segments will copy from the one before it except for the neck
body[i]->SetDirection(body[i-1]->GetDirection(), (i == length-1));
body[i]->position = body[i-1]->position;
}
// neck will copy its direction and position from the head
body[0]->SetDirection(dir, (length == 1));
body[0]->position = position;
}
76. Test!
Ê Once
you’re
done
implementing
SetDirection(),
build
and
run
your
program
Ê Ideally,
the
snake’s
body
would
be
more
realistic
J
Ê See
src/SnakeGD4N-‐05
for
the
solution
78. Food
Ê The
food
is
a
simple
game
object
in
the
sense
that
it
doesn’t
perform
any
logic
until
something
collides
with
it.
Upon
collision,
the
food
simply
randomizes
its
position.
Ê Our
food
will
use
an
animated
sprite
sheet
that
has
an
oscillating
animation.
Meaning,
it
animates
from
frame
0
to
3
then
back
to
0
and
repeats,
given
that
the
animation
only
has
4
frames.
79. Collisions
Ê To
work
with
collisions,
we
first
need
to
set
the
different
game
object
types
Ê Add
the
following
enum
in
constants.h
enum GAMEOBJECT_TYPES {
TYPE_FOOD = 1,
TYPE_SNAKE,
TYPE_SNAKESEGMENT,
TYPE_GROUND,
};
80. Type
Ê Set
the
type
of
each
game
object
in
their
constructor
Ê This
will
affect
CSnake.cpp,
CSnakeSegment.cpp
and
CGround.cpp
Ê If
this
step
is
skipped,
collisions
will
not
be
detected
85. CFood
Collision
Reaction
void CFood::CollidesWith(GD4N::CGameObject* other) {
switch (other->GetType()) {
case TYPE_SNAKESEGMENT:
case TYPE_FOOD:
case TYPE_GROUND:
// Respawn!
do {
RandomizePosition();
} while (IsCollidingWith(other));
break;
case TYPE_SNAKE:
// Snake ate this food!
RandomizePosition();
break;
}
}
86. CGround
GetWidth()
and
GetHeight()
Ê Notice
that
CFood::IsCollidingWith()
requires
GetWidth()
and
GetHeight()
from
CGround.
Simply
add
these
2
methods
in
CGround
that
returns
the
width
and
height
respectively.
87. Test!
Ê Build
and
run
the
program.
Ê The
food
should
be
randomly
generated
in
the
area.
Ê When
the
snake
head
eats
(collides
with)
the
food,
the
food
will
be
placed
in
a
different
random
position.
Ê See
src/SnakeGD4N-‐06
for
any
clarifications
89. Snake
Collisions
Ê The
snake
only
has
2
collision
reactions;
death
and
grow
Ê When
a
snake
consumes
(collides)
with
the
food,
the
desired
length
of
the
snake
increments
by
1.
Thus,
we
no
longer
need
the
quick
fix
of
pressing
the
space
bar
to
increase
the
length.
Ê When
a
snake
collides
with
anything
else
(another
snake
head,
a
snake
body
regardless
of
who
it
belongs
to,
the
ground),
the
snake
will
die.
Ê We
simply
need
to
override
the
IsCollidingWith()
and
CollidesWith()
methods
from
CGameObject.
91. CSnake
Collision
Reaction
Ê Note:
SAudioManager.h
should
be
included
void CSnake::CollidesWith(GD4N::CGameObject* other) {
switch (other->GetType()) {
case TYPE_FOOD:
desiredLength++;
sAudio->PlaySound(SFXID_EAT);
break;
default:
// die
isActive = false;
break;
}
}
92. Test!
Ê Build
and
run
your
code.
Ê Test
if
all
the
collision
reactions
are
correct.
Ê Note
that
the
quick
fix
of
pressing
space
to
increase
the
snake’s
length
should
be
removed.
Ê See
src/SnakeGD4N-‐07
for
any
clarifications
94. Snake
Ê Now
that
we
have
the
core
gameplay
working,
we
will
polish
the
game.
Ê We
first
add
a
Title
Screen
where
the
player
could
select
between
single
player
and
2
players.
Also,
the
Title
Screen
will
give
the
player
an
option
to
exit
the
game.
95. CTitle
Ê The
Title
Screen
is
actually
another
Game
Object.
This
is
true
for
most
games
–
the
GUI
is
a
Game
Object.
Ê The
main
difference
between
this
Game
Object
will
be
the
overriding
of
DrawGUI().
This
method
is
where
we
perform
all
GUI-‐related
functionality.
96. CTitle.h
#include "CGameObject.h"
class CTitle : public GD4N::CGameObject {
protected:
int selected;
public:
CTitle();
void Update();
void DrawGUI();
};
98. CTitle
Update
void CTitle::Update() {
if (sInput->GetKey(SDLK_ESCAPE)) {
sGameManager->StopPlaying(); // quit game
}
if (sInput->GetKeyDown(SDLK_DOWN)) {
selected++;
} else if (sInput->GetKeyDown(SDLK_UP)) {
selected--;
}
selected = (selected + 3) % 3;
if (sInput->GetKeyDown(SDLK_RETURN)) {
switch (selected) {
case 0: sGameManager->ChangeScene(1); break;
case 1: sGameManager->ChangeScene(2); break;
case 2: sGameManager->StopPlaying(); break;
}
}
}
99. CTitle
DrawGUI
Ê The
DrawGUI()
is
a
bit
more
complicated
than
the
Draw()
methods
because
we’re
handling
different
images
at
once.
void CTitle::DrawGUI() {
using GD4N::TVector2;
sVideo->Draw(SURFID_TITLE, TVector2<int>(73, 50));
sVideo->Draw(SURFID_TITLEOPTION1, TVector2<int>(170, 200));
sVideo->Draw(SURFID_TITLEOPTION2, TVector2<int>(170, 250));
sVideo->Draw(SURFID_TITLEOPTION3, TVector2<int>(170, 300));
switch (selected) {
case 0:
sVideo->Draw(SURFID_SELOPTION, TVector2<int>(140, 200));
break;
case 1:
sVideo->Draw(SURFID_SELOPTION, TVector2<int>(140, 250));
break;
case 2:
sVideo->Draw(SURFID_SELOPTION, TVector2<int>(140, 300));
break;
}
}
100. Adding
the
Scenes
Ê Now
that
we
have
the
Title
screen,
we
need
to
add
scenes
which
will
show
the
Title
screen
first
before
going
to
the
different
scenes.
Ê In
CSnakeGameManager.h,
add
Scene01()
and
Scene02()
similar
to
Scene00().
Ê Register
these
scenes
in
CSnakeGameManager.cpp
similar
to
Scene00()
in
the
Init().
Ê Add/modify
the
scenes
to
be
similar
to
the
next
slide.
Note
that
the
appropriate
headers
have
been
included.
101. Scene
Definitions
void CSnakeGameManager::Scene00() {
new CGround();
new CTitle();
}
void CSnakeGameManager::Scene01() {
new CGround();
new CSnake();
new CFood();
}
void CSnakeGameManager::Scene02() {
new CGround();
}
102. Test!
Ê Build
and
run
your
program!
Ê The
game
should
begin
with
the
Title
Screen
where
you
can
select
the
number
of
players
by
pressing
the
up
or
down
arrow
keys
then
pressing
enter
to
confirm
the
selection.
Ê Selecting
QUIT
exits
the
game.
Ê Select
1
Player
goes
to
basic
gameplay
with
1
player.
Ê Select
2
Player
and
it
enters
an
empty
scene
(except
for
the
ground).
Ê See
src/SnakeGD4N-‐08
for
any
clarifications
104. In-‐Game
Menu
Ê Purpose:
Ê Pause
the
Game
Ê Return
to
Title
Screen
Ê Similar
to
CTitle,
CInGameMenu
is
a
game
object
that
overrides
DrawGUI()
instead
of
Draw()
Ê What’s
special
with
CInGameMenu
is
that
it
should
be
able
to
freeze
all
the
snakes
in
the
game
when
the
game
is
paused.
Therefore,
CInGameMenu
should
have
a
container
of
game
objects
to
pause/resume.
108. CInGameMenu.cpp
void CInGameMenu::Update() {
if (sInput->GetKeyDown(SDLK_ESCAPE)) {
SetObjectsActive(isVisible);
isVisible = !isVisible;
selected = 0;
}
if (isVisible) {
if (sInput->GetKeyDown(SDLK_DOWN)) {
selected++;
} else if (sInput->GetKeyDown(SDLK_UP)) {
selected--;
}
selected &= 1; // limit to 0 or 1 only
if (sInput->GetKeyDown(SDLK_RETURN)) {
switch (selected) {
case 0:
SetObjectsActive(isVisible);
isVisible = false;
break;
case 1:
// return to title screen
sGameManager->ChangeScene(0);
break;
}
}
}
}
109. Modify
Scene01
Ê Now
that
we
have
the
CInGameMenu,
we
add
it
in
Scene01()
and
register
the
snakes
to
it.
void CSnakeGameManager::Scene01() {
new CGround();
new CFood();
CSnake *snake = new CSnake();
CInGameMenu *igm = new CInGameMenu();
igm->AddGameObject(snake);
}
110. Test!
Ê Build
and
run
your
program!
Ê From
the
Title
Screen,
select
1
Player
Ê Press
ESC
to
open
the
In-‐Game
Menu.
Notice
how
the
snakes
stop
moving.
Press
ESC
again
or
select
resume
and
press
enter
to
resume
the
game
Ê See
src/SnakeGD4N-‐09
for
any
clarifications
Ê The
In-‐Game
Menu
also
allows
the
player
to
leave
the
game
when
the
snake
dies
112. 2
Player
Ê Since
we’ve
completed
the
single
player
of
snake,
it’s
time
to
modify
it
to
become
2-‐player.
Most
of
the
modifications
are
in
CSnake
Ê Things
to
do:
Ê The
snake
should
have
a
way
to
know
if
it’s
first
or
second
player
Ê Depending
on
the
player
number;
their
initial
position,
initial
direction
and
controls
should
differ
Ê There
should
be
a
way
to
differentiate
one
player
from
the
other
Ê Both
snakes
need
to
be
paused
by
the
in-‐game
menu