Did a lot of work on the engine

This commit is contained in:
2021-05-16 11:22:45 -07:00
parent 80f9cc4328
commit e958f509ab
46 changed files with 960 additions and 362 deletions

18
include/dawn/util/math.h Normal file
View File

@ -0,0 +1,18 @@
// Copyright (c) 2021 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
/**
* Returns the modulous a result for b. Consdiders negative numbers correctly.
* @param a Number to modulo against. (a % b)
* @param b Number to modulo with. (a % b)
*/
#define mathMod(a,b) (a%b+b)%b
#define mathMax(a,b) (a<b?b:a)
#define mathMin(a,b) (a>b?b:a)
#define mathAbs(n) (n<0?-n:n)
#define mathDeg2Rad(n) (n * M_PI / 180.0)
#define mathRad2Deg(n) (n * 180 / M_PI)

28
include/dawn/util/rand.h Normal file
View File

@ -0,0 +1,28 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include <dawn/dawn.h>
/**
* Generate a number between 0 and max. (max exclusive)
*
* @param max Max number to generate
* @return Number between 0 and max.
*/
#define u32rand(max) (rand()%max)
#define u8rand(max) (uint8_t)u23rand(max)
/**
* Generate a number between min and max. (max exclusive, min inclusive)
*
* @param min Min number to generate.
* @param max Max number to generate.
* @return Number between min and max.
*/
#define u32randRange(min, max) (u32rand(max-min)+min)
#define u8randRange(min, max) (uint8_t)u32randRange(min,max)