Allegro Basics Game Library.

Slides:



Advertisements
Similar presentations
CPSC 441 TUTORIAL – JANUARY 16, 2012 TA: MARYAM ELAHI INTRODUCTION TO C.
Advertisements

Practical techniques & Examples
C Programming - Lecture 5
C Basic File Input/Output Manipulation C Programming – File Outline v File handling in C - opening and closing. v Reading from and writing to files.
RAS-Group, SoC, NUS (BAP: CS5234) Page 1 RAS Meeting (October-2002) J BAP Partitioning Challenge oPartitioning only – not packing J The BAP Software Overview.
ITEC 320 C++ Examples.
Chapter 8 Scope of variables Name reuse. Scope The region of program code where it is legal to reference (use) a variable The scope of a variable depends.
111 Introduction to OGRE3D Programming: Main Loop.
Operating Systems Process Creation
Variables  A piece of memory set aside to store data  When declared, the memory is given a name  by using the name, we can access the data that sits.
CS241 Systems Programming Discussion Section Week 2 Original slides by: Stephen Kloder.
Revisiting building. Preprocessing + Compiling 2 Creates an object file for each code file (.c ->.o) Each.o file contains code of the functions and structs.
Computer Graphics -practical- Lecture 6. (visual c++) open gl library To use open GL with VC++ we add these files:- 1)Glut.h C:\program files\ Microsoft.
Section 5.5 Application: The Card Game of War. 5.5 Application: The Card Game of War A deck of cards is shuffled and dealt to two players The players.
History of C and basics of Programming
Lesson #5 Repetition and Loops.
Reference: Object Oriented Design and Programming (Horstmann)
Test 2 Review Outline.
Review 1.
Prof: Dr. Shu-Ching Chen TA: Samira Pouyanfar Spring 2017
Content Programming Overview The JVM A brief look at Structure
Chapter 6 CS 3370 – C++ Functions.
Repetition Structures
5.13 Recursion Recursive functions Functions that call themselves
PYGAME.
CISC105 – General Computer Science
Lesson #5 Repetition and Loops.
Classes and Objects in Java
IF statements.
Variables A piece of memory set aside to store data
Programming Scratch to Control a K’NEX Fairground Ride
Introduction to Programmng in Python
Multi-dimensional Array
Lecture 07 More Repetition Richard Gesick.
Engineering Innovation Center
Writing Functions( ) (Part 5)
Multiple Files Revisited
Lesson #5 Repetition and Loops.
Introduction to pseudocode
Logical assertions assertion: A statement that is either true or false. Examples: Java was created in The sky is purple. 23 is a prime number. 10.
Truth tables: Ways to organize results of Boolean expressions.
Exam 4 review Copyright © 2008 W. W. Norton & Company.
Putting the I in IoT.
Govt. Polytechnic,Dhangar
Reference Parameters.
Module 4 Loops.
Truth tables: Ways to organize results of Boolean expressions.
Game Loop Update & Draw.
Chapter 6: Repetition Statements
Classes and Objects in Java
Problem Solving Designing Algorithms.
Homework Applied for cs240? (If not, keep at it!) 8/10 Done with HW1?
CLASSES, AND OBJECTS A FIRST LOOK
Truth tables: Ways to organize results of Boolean expressions.
Flowcharts and Pseudo Code
Overview of Java 6-Apr-19.
IPC144 Introduction to Programming Using C Week 4 – Lesson 1
CHAPTER 4 File Processing.
Lesson #5 Repetition and Loops.
Agenda Warmup Lesson 1.9 (random #s, Boolean variables, etc)
C Programming - Lecture 5
Classes and Objects in Java
C Programming - Lecture 3
Intro to the Shell with Fork, Exec, Wait
SPL – PS1 Introduction to C++.
GCSE Computing.
Matlab tutorial course
Switch Case Structures
Agenda Warmup Lesson 1.9 (random #s, Boolean variables, etc)
Presentation transcript:

Allegro Basics Game Library

What is Allegro? Allegro is a cross-platform library intended for use in computer games and other types of multimedia programming. Cross-platform support for Windows, Unix, and MacOS X systems.

License? The giftware licence Feel free to use the code for whatever you want – just do not claim that you wrote it!

Using Allegro any source file which used Allegro functions or variables must #include <allegro5/allegro.h> Put this after any standard header files you should call al_init() near the start of your program. make al_init() the first thing in your main function.

More on Allegro Usage Link with the appropriate Allegro Library DLLs must be available for Allegro programs to run (either in current directory or Windows/System directory)

What does a game need to do? Initialization - First of all we need to put the game into a known state, so that it always starts in the same way. For example, you might want to start the player in the middle of the screen, make a maze, or create a random map. All that would go in here. Main game loop The game will need to keep doing things, over and over again, until the player dies, wins, gives up, or whatever. So we have a main game loop. It has three main components: Input -- getting input from the player Processing -- moving things around, responding to the input Output -- sending information back to the player, usually by putting it on the screen but sometimes by other means, for example playing sounds After the game - When the game has finished, we may need to do some other things, like tell the player why it finished, update a high score table, or something like that

Proposed Main int main(int argc, const char *argv[]) { if (argc > 1) filename = argv[1]; } else filename = "mysha.pcx"; initialize_allegro(); initialize_display(); initialize_timer(); keep_on = true; while (keep_on) process_events(); process_display(); process_cleanup(); return 0;

Proposed Initializaton void initialize_allegro() { if (!al_init()) abort_example("Could not init Allegro.\n"); } al_install_mouse(); al_install_keyboard(); al_init_image_addon();

Making the display display = al_create_display(800, 600); if (!display) { abort_example("Error creating display\n"); } al_set_window_title(display, filename);();

Making the Bitmap al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP); t0 = al_get_time(); membitmap = al_load_bitmap(filename); t1 = al_get_time(); if (!membitmap) { abort_example("%s not found or failed to load\n", filename); } al_set_new_bitmap_flags(ALLEGRO_VIDEO_BITMAP);

Making the Display ALIVE al_clear_to_color(al_map_rgb_f(0, 0, 0)); if (zoom == 1) al_draw_bitmap(bitmap, 0, 0, 0); else al_draw_scaled_rotated_bitmap( bitmap, 0, 0, 0, 0, zoom, zoom, 0, 0); al_flip_display();