This file contains 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
#include "arrlist.h" | |
#include <math.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#define EXTRA_CAPACITY 4 | |
#define RESZ_NUMER 5 | |
#define RESZ_DENOM 3 | |
#define MAX(x, y) ((x) > (y) ? (x) : (y)) |
This file contains 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
void resolve_object_tile_collision(sf::Vector2f& tl_object_position, sf::Vector2f& tl_object_velocity, std::uint8_t* tile_data, std::uint32_t tiles_width, std::uint32_t tiles_height) { | |
//Using a method of AABB collision detection that handles the response between the tile it most intersects first. | |
std::vector<std::pair<float, sf::Vector2i>> tile_intersections; //Pairs consisting of the intersection area of a tile with its relative position | |
//Populate tile_intersections | |
sf::Vector2i prime_tile_pos( //Tile the object's top left corner rests within | |
int(std::floor(tl_object_position.x / 64.f)), | |
int(std::floor(tl_object_position.y / 64.f)) | |
); | |
for (int8_t y = 0; y <= 1; ++y) { | |
for (int8_t x = 0; x <= 1; ++x) { |
This file contains 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
#include <stdint.h> | |
#include "Tilemap.hpp" | |
Tilemap::Tilemap(const sf::Vector2u& map_dimensions, const sf::Vector2u& tile_dimensions, sf::Texture* texture, uint8_t* tile_data_pointer) : | |
_vertices(sf::Triangles, map_dimensions.x * map_dimensions.y * 6u), | |
_map_dimensions(map_dimensions), | |
_tile_dimensions(tile_dimensions), | |
_texture(texture), | |
_tile_data_pointer(tile_data_pointer) | |
{ |
This file contains 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
#include <SFML/Graphics.hpp> | |
int main(){ | |
sf::RenderWindow window(sf::VideoMode(1024u, 576u), "LD31");{ | |
window.setFramerateLimit(60u); | |
} | |
sf::CircleShape circle(32.f); | |
while(window.isOpen()){ | |
sf::Event event; | |
while(window.pollEvent(event)){ |
This file contains 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
#ifndef H_TILEMAP | |
#define H_TILEMAP | |
#include <array> | |
#include <SFML/Graphics.hpp> | |
class TexBoxCoords : public sf::Rect<int> { | |
public: | |
TexBoxCoords(void) : | |
sf::Rect<int>() |