π
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>RI: Breakout Examples</title> | |
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/phaser.min.js"></script> | |
</head> | |
<body> | |
<script> | |
class Breakout extends Phaser.Scene | |
{ | |
constructor () |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WINDOW_WIDTH = 512 | |
WINDOW_HEIGHT = 712 | |
RUNAWAY_HEIGHT = 40 | |
CHARACTER_WIDTH = 24 | |
CHARACTER_HEIGHT = 24 | |
CHARACTER_SCALE = 4 | |
CHARACTER_ANIMATION_CHANGE = 0.065 | |
CHARACTER_VERTICAL_SPEED = -500 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WINDOW_WIDTH = 512 | |
WINDOW_HEIGHT = 916 | |
CROW_WIDTH = 48 | |
CROW_HEIGHT = 48 | |
CROW_ANIMATION_CHANGE = 0.25 | |
function engine.start() | |
engine.window.setTitle("Animated Crow?!") | |
engine.window.setWindowSize(WINDOW_WIDTH, WINDOW_HEIGHT) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Exercise 32.1: | |
// Write a library that allows a script to limit the total amount | |
// of memory used by its Lua state. | |
// It may offer a single function, setlimit, | |
// to set that limit. | |
// The library should set its own allocation function. | |
// This function, | |
// before calling the original allocator, | |
// checks the total memory in use and returns NULL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Exercise 31.3: | |
// Implement in the lproc library a non-blocking send operation. | |
#define LUA_COMPAT_MODULE | |
#define LUA_COMPAT_APIINTCASTS | |
#include <cstdint> | |
#include <iostream> | |
#include <pthread.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Exercise 31.2: | |
// Modify the lproc library so that | |
// it can send and receive other primitive types such as | |
// booleans and numbers. | |
// (Hint: you only have to modify the movevalues function.) | |
#define LUA_COMPAT_MODULE | |
#define LUA_COMPAT_APIINTCASTS | |
#include <cstdint> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Exercise 30.1: | |
// Modify the dir_iter function in the directory example | |
// so that it closes the DIR structure when it reaches | |
// the end of the traversal. | |
// With this change, | |
// the program does not need to wait for a garbage collection | |
// to release a resource that it knows it will not need anymore. | |
// (When you close the directory, | |
// you should set the address stored in the userdatum to NULL, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Exercise 29.4: | |
// Based on the example for boolean arrays, | |
// implement a small C library for integer arrays. | |
#define LUA_COMPAT_APIINTCASTS | |
#include <cmath> | |
#include <cstdint> | |
#include <exception> | |
#include <iomanip> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Exercise 29.2: | |
// We can see a boolean array as a set of integers | |
// (the indices with true values in the array). | |
// Add to the implementation of boolean arrays | |
// functions to compute | |
// the union and intersection of two arrays. | |
// These functions should receive two arrays and return a new one, | |
// without modifying its parameters. | |
// Exercise 29.3: |
NewerOlder