1
0
Fork 0

added sara.objectionable.solutions

This commit is contained in:
Sara Gerretsen 2025-12-28 11:55:25 +01:00
parent 95f5378727
commit df7ab8720f
26 changed files with 1217 additions and 0 deletions

View file

@ -0,0 +1,220 @@
<!DOCTYPE html>
<html>
<head>
<title>Boids - Sara Gerretsen</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="../shared/jquery.min.js"></script>
<link rel="stylesheet" href="../shared/style.css">
<div id="site-header">
<script>$(function(){$("#site-header").load("../shared/header.html");});</script>
</div>
</head>
<body>
<h1 id="version-2">Boids (ecs)</h1>
<section>
<h2 id="info-v2">Info</h2>
<div indented>
<p>Project type: C Simulation</p>
<p>Timeframe: 2022</p>
</div>
<h2 id="video-v2">Video</h2>
<iframe
src="https://www.youtube.com/embed/unTQRpplFGU?mute=1&loop=1&autoplay=1"
class="embed" youtube
></iframe>
<p>
The repository for the boids simulation.
</p>
<a class="internal" target="_blank" href="https://git.saragerretsen.nl/Sara/boids-ecs">
<div class="git-block">
<div class="git-logo"></div>
<h2>Sara/boids-ecs</h2>
</div>
</a>
<p>
The ecs library i wrote this for.
</p>
<a class="internal" target="_blank" href="https://git.saragerretsen.nl/Sara/easy-ecs">
<div class="git-block">
<div class="git-logo"></div>
<h2>Sara/easy-ecs</h2>
</div>
</a>
<h2 id="product-overview-v2">Product Overview</h2>
<p indented>
My second implementation of a <a href="https://en.wikipedia.org/wiki/Boids">boids simulation</a>. This time written in C using a combination of SDL2 for rendering and a self-made ecs library for object management.
The program includes a ui window which allows users to modify the settings of the boids at runtime.
</p>
<h2 id="project overview-v2">Project Overview</h2>
<p indented>
This was made as a stress test of a pure C entity-component-system library I was building for myself.
During the development of the boid simulation i managed to improve the ECS it was build around by multithreading it. As well as improving lookup times through binary search.
Both of which are rather rudimentary improvements i wanted to make, but the stress test not only made it more obvious they were needed, but also made it much more measurable when they worked.
</p>
<h2 id="architecture-v2">Modules</h2>
<div indented>
<p>
The program is split into a set of distinct submodules. The <i>ecs</i>, <i>adb</i>, <i>ui</i>, <i>engine</i> and <i>sim</i> modules.
Of these modules the adb and ecs modules are entirely standalone, the ui module depends only on <a href="https://www.libsdl.org/">SDL2</a>, the engine is dependent on all others except sim, and sim is dependent on engine.
</p>
<img src="../assets/boids-ecs-dependency-graph.png">
<h2 id="code-v2">Code</h2>
<p style="font-style:italic; font-weight:200; color:#777F" indented>
NOTE: Most of these modules were developed separately and as standalone libraries. As such, they have vastly differing naming conventions.
Still, each module is internally consistent about its own naming scheme. I just tend to switch style every project.
For clarity, the ecs and ui modules use camelCase while the adb, engine and sim modules all use snake_case.
</p>
<h3>Engine</h3>
<p>
The engine module provides the program's entry point and update/render/event loops. It communicates with the sim by declaring three functions as extern without defining them. The sim then defines them allowing the engine to call functions from the sim.
The functions in question are:
<ul>
<li><i>sim_config</i>, which allows the sim to configure important parts of the engine by adjusting a settings struct.</li>
<li><i>sim_init</i> this is called after all other modules are initialized and allows the sim to initialize its components, systems and entities, as well as load assets.</li>
<li><i>sim_quit</i> which gives the simulation the chance to clean up any allocated resources after the main loop ends but before the other modules are terminated.</li>
</ul>
</p>
<div class="code-box code-content" id="engine-sim-interaction">
<script>
$(function(){$("#engine-sim-interaction").load("https://raw.githubusercontent.com/Sara-G-GD/portfolio-code-highlighting/main/engine-sim-interaction.html");});
</script>
</div>
<h3>Sim</h3>
<p>
The sim module is the only module that actually interacts with anything boid-specific. Whereas the other modules are more so supporting of the simulation.
The sim can be divided further into the part that interacts with the engine module, and the part that actually models and simulates the boids.
The part that interacts with the engine is responsible for registering components and systems with the ecs, loading assets, and spawning the boids.
</p>
<div class="code-box code-content" id="sim-init">
<script>
$(function(){$("#sim-init").load("https://raw.githubusercontent.com/Sara-G-GD/portfolio-code-highlighting/main/boids-sim-init.html");});
</script>
</div>
<p>
The second part of the sim module are the functions that make the boids behave the way they do. The ones that run as systems from the ecs all follow the signature of an ecs system function. They take in a list of entities, a list of the corresponding component masks, the number of items in both lists, and the delta time of the current frame. They then loop over the entities and perform specific actions for each one. In order to avoid looping over every boid in the simulation every frame, for every boid. The boids cache boids that are within the range of the behaviour with the furthest range.
</p>
<div class="code-box code-content" id="boid-update-near">
<script>
$(function(){$("#boid-update-near").load("https://raw.githubusercontent.com/Sara-G-GD/portfolio-code-highlighting/main/boid-update-near.html");});
</script>
</div>
<p>
When the boids that are close enough to interact have all been cached, the actually modifying systems start running. As a demonstration is the separation system, which keeps the boids apart from eachother to avoid all of them forming a singularity. For each boid, the system loops through all nearby boids, keeping a running average of the positions of each boid nearby enough to be within range. After all nearby boids have been accounted for, the boid's velocity is adjusted to move away from the calculated average.
</p>
<div class="code-box code-content" id="boid-separation">
<script>
$(function(){$("#boid-separation").load("https://raw.githubusercontent.com/Sara-G-GD/portfolio-code-highlighting/main/boids-ecs-separation.html");});
</script>
</div>
<p>
Cohesion and alignment are similar enough that i wont place them here. Cohesion is the opposite of separation, and alignment is practically the same but with velocity instead of position.
The mouse does the same as cohesion but with the mouse, and thus without the need for an average. The wall behaviour pushes the boids back onto the screen when they exit it.
</p>
<h3>ECS</h3>
<p>
The <a href="https://en.wikipedia.org/wiki/Entity_component_system">entity-component-system (ecs)</a> module manages the runtime object model where Entities are numbers, Components are blocks of memory attached to an entity and Systems are function pointers with a component requirement. This is the library that the boids where made to test.
The below code consists of snippets showing initialization and uses of components systems and entities.
</p>
<div class="code-box code-content" id="ecs-demo">
<script>
$(function(){$("#ecs-demo").load("https://raw.githubusercontent.com/Sara-G-GD/portfolio-code-highlighting/main/ecs-systems-usage.html");});
</script>
</div>
<h3>Asset database</h3>
<p>
The asset database (adb) module is the module responsible for managing asset data. So it has functions for loading data from files, getting loaded file data, and releasing data after it is no longer needed. To keep this module generic, it has runtime defined rules for managing files through file handler functions.
</p>
<div class="code-box code-content" style="overflow-x:hidden" id="load-asset">
<script>
$(function(){$("#load-asset").load("https://raw.githubusercontent.com/Sara-G-GD/portfolio-code-highlighting/main/intended-adb-loading.html");});
</script>
</div>
<h3>UI</h3>
<p>
The ui module is based on the <a href="https://en.wikipedia.org/wiki/Immediate_mode_GUI">immediate mode graphical user interface (imgui)</a> paradigm. This is a paradigm where there is no intermediate storage between the gui and the data. The gui directly modifies the data and vice versa.
In my implementation this is done by sending the gui functions pointers to the data they represent as parameters.
</p>
<div class="code-box code-content" id="ui-demo">
<script>
$(function(){$("#ui-demo").load("https://raw.githubusercontent.com/Sara-G-GD/portfolio-code-highlighting/main/ui-module-boids.html");});
</script>
</div>
</section>
<h1 id="version-1" style="margin-top:4em">Boids (steering behaviours)</h1>
<section class="project">
<h2>Info</h2>
<div indented>
<p>Project type: C++ Simulation</p>
<p>Timeframe: 2022</p>
</div>
<h2 id="video-v1">Video</h2>
<iframe
src="https://www.youtube.com/embed/h6zuPfniL2s?mute=1&loop=1&autoplay=1"
class="embed" youtube
></iframe>
<h2 id="product-overview-v1">Product Overview</h2>
<p indented>
My first version of a boids simulation. Written in C++ with sfml.
</p>
<h2 id="project-overview-v1">Project Overview</h2>
<p indented>
I worked on this for about week inspired by the lessons on steering behaviours at school.
</p>
<h2 id="code-v1">Code</h2>
<div indented>
<h3>Boid</h3>
<div indented>
<p>
The boids themselves are primarily a position, a velocity, a mass, and a collection of behaviour function pointers. These boids are then stored in a vector and each of the behaviours is run for each of the boids, resulting in the demonstrated movements.
</p>
<div id="code-boids" class="code-content code-box">
<script>
$(function(){$("#code-boids").load("https://raw.githubusercontent.com/Sara-G-GD/portfolio-code-highlighting/main/boids-boids.html");});
</script>
</div>
</div>
<h3>Behaviours</h3>
<div indented>
<p>
As previously mentioned, the boids all store a collection of behaviours, represented by function pointers. These function pointers take as input a context object representing the program state at the start of the frame, and output a desired change in velocity. The original boids paper describes cohesion, separation, and alignment, so these are the main behaviours implemented.
</p>
<div id="code-behaviour-cohesion" class="code-content code-box">
<script>
$(function(){$("#code-behaviour-cohesion").load("https://raw.githubusercontent.com/Sara-G-GD/portfolio-code-highlighting/main/cohesion-boids.html");});
</script>
</div>
<div id="code-behaviour-separation" class="code-content code-box">
<script>
$(function(){$("#code-behaviour-separation").load("https://raw.githubusercontent.com/Sara-G-GD/portfolio-code-highlighting/main/separation-boids.html");});
</script>
</div>
<div id="code-behaviour-alignment" class="code-content code-box">
<script>
$(function(){$("#code-behaviour-alignment").load("https://raw.githubusercontent.com/Sara-G-GD/portfolio-code-highlighting/main/alignment-boids.html");});
</script>
</div>
</div>
</div>
</section>
</html>

View file

@ -0,0 +1,67 @@
<!DOCTYPE html>
<html>
<head>
<title>GML Tile Movement - Sara Gerretsen</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="../shared/style.css">
<link rel="stylesheet" href="../shared/projects.css">
<script type="text/javascript" src="../shared/jquery.min.js"></script>
<div id="site-header">
<script>$(function(){$("#site-header").load("../shared/header.html");});</script>
</div>
</head>
<body>
<h1>Tile Movement</h1>
<section class="project">
<h2>Info</h2>
<div indented>
<p>Project Type: Gamemaker 2 Game</p>
<p>Timeframe: 2019</p>
</div>
<h2>Video</h2>
<iframe indented
src="https://www.youtube.com/embed/kmEV8TqBAHQ?mute=1&autoplay=1&loop=1"
class="embed" youtube>
</iframe>
<h2>Product Overview</h2>
<p indented>
One of my older projects. This is a prototype of a tile based movement system focused on getting smooth responsive movement with directional input.
Move around, defeat the enemies and move on to the next room. Made around 2019 or so.
</p>
<h2>Project Overview</h2>
<p indented>
Made on my own over a few days, main focus was on getting a smooth feeling tile based movement system in gamemaker, which was my engine of choice at the time.
After the movement was implemented I made some sprites, levels and a simple 'pathfinding' system that picks the unoccupied tile that is closest to the target.
</p>
<h2>Code</h2>
<div indented>
<h3>Try Move</h3>
<div indented>
<p>
The main challenge was allowing characters to move around without phasing into walls or eachother. The try-move
function is a generic solution to this problem.
It tests if the proposed movement would overlap with a non-walkable tile on the floor map. As well as testing if
any other character is trying to move to that position.
</p>
<div id="code-try-move" class="code-content code-box">
<script>$(function(){ $("#code-try-move").load("https://raw.githubusercontent.com/Sara-G-GD/portfolio-code-highlighting/main/try-move-gmldc.html");});</script>
</div></div>
<h3>AI Movement</h3>
<p>
The AI in the game is a simple example of how the try move function could be used in context.
</p>
<div id="code-ai-move" class="code-content code-box">
<script>$(function(){$("#code-ai-move").load("https://raw.githubusercontent.com/Sara-G-GD/portfolio-code-highlighting/main/update-ai-gmldc.html");});</script>
</div>
</div>
</section>
</body>
</html>

View file

@ -0,0 +1,82 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Project VTD - Sara Gerretsen</title>
<script type="text/javascript" src="../shared/jquery.min.js"></script>
<link rel="stylesheet" href="../shared/style.css">
<div id="site-header">
<script>$(function(){$("#site-header").load("../shared/header.html");});</script>
</div>
</head>
<body>
<h1>Tower VR</h1>
<section class="project">
<h2>Info</h2>
<div indented>
<p>Project Type: Unreal Engine VR Game</p>
<p>Project Timeframe: 2022</p>
</div>
<h2>Video</h2>
<iframe
src="https://www.youtube.com/embed/BtUpfEFvFr4?mute=1&loop=1&autoplay=1"
class="embed" youtube>
</iframe>
<!--BtUpfEFvFr4-->
<h2>Product Overview</h2>
<p indented>
A VR tower defence game where the player can fight enemies with their sword, or build towers by drawing patterns on a magic circle.
</p>
<h2>Project Overview</h2>
<p indented>
The game was made at a 'Hybride Leeromgeving' (Eng: Hybrid Learning Environment) or HLO. Which gives students the opportunity to work in an environment closer to that of a professional game company. The game was made with a team of five programmers and one artist.
</p>
<h2>Code</h2>
<div indented>
<h3>Tower Selection</h3>
<div indented>
<p>
One of the mechanics I was responsible for was the tower selection circles. The code calls them spell circles as they were initially supposed to cast spells.
Spell circles spawn a pattern of orbs with colliders, these orbs have their own logic to send a message to a 'spell map' contained within the spell circle.
</p>
<i>spell circle - interface declaration</i>
<div id="spell-circle-h" class="code-content code-box">
<script>$(function(){$("#spell-circle-h").load("https://raw.githubusercontent.com/Sara-G-GD/portfolio-code-highlighting/main/vtd-spell-circle-h.html");});</script>
</div>
<i>spell circle - implementation</i>
<div id="spell-circle-c" class="code-content code-box">
<script>$(function(){$("#spell-circle-c").load("https://raw.githubusercontent.com/Sara-G-GD/portfolio-code-highlighting/main/vtd-spell-circle-c.html");});</script>
</div>
<p>
These 'orbs' all know their own index within the spell circle's list of orbs. When an orb is hit, it sends its own index to the spell map component of the spell circle. This number is then converted to a string and appended to the spell map's pattern string. Because of the way the system works, only 1 digit indexes are used, though the code does not enforce this.
Whenever a new character is added, the spell map compares the formed string to a list of 'correct' patterns.
If the string produced after the last addition does not match a substring of the same length in a 'correct' pattern, the pattern is considered failed and the corresponding event is triggered.
When the string produced is equal to a 'correct' pattern, the event signalling a correct pattern is triggered.
Because a large part of the team prefered working with blueprints, a lot of the C++ architecture was designed with an eye on its blueprint interface. This lead to some odd decisions regarding the "success" event, as blueprints were unable to interact with the map of delegates to patterns that was used in the initial version of the spell map (hence the name).
</p>
<i>spell map - interface declaration</i>
<div id="spell-map-h" class="code-content code-box">
<script>$(function(){$("#spell-map-h").load("https://raw.githubusercontent.com/Sara-G-GD/portfolio-code-highlighting/main/vtd-spell-map-h.html");});</script>
</div>
<i>spell circle - implementation</i>
<div id="spell-map-c" class="code-content code-box">
<script>$(function(){$("#spell-map-c").load("https://raw.githubusercontent.com/Sara-G-GD/portfolio-code-highlighting/main/vtd-spell-map-c.html");});</script>
</div>
<i>spell orb - interface declaration</i>
<div id="spell-orb-h" class="code-content code-box">
<script>$(function(){$("#spell-orb-h").load("https://raw.githubusercontent.com/Sara-G-GD/portfolio-code-highlighting/main/vtd-spell-orb-h.html");});</script>
</div>
<i>spell orb - implementation</i>
<div id="spell-orb-c" class="code-content code-box">
<script>$(function(){$("#spell-orb-c").load("https://raw.githubusercontent.com/Sara-G-GD/portfolio-code-highlighting/main/vtd-spell-orb-c.html");});</script>
</div>
</div>
</div>
</section>
</body>
</html>

View file

@ -0,0 +1,67 @@
<!DOCTYPE html>
<html>
<head>
<title>Ruins of Edis - Sara Gerretsen</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="../shared/jquery.min.js"></script>
<link rel="stylesheet" href="../shared/style.css">
<div id="site-header">
<script>$(function(){$("#site-header").load("../shared/header.html");});</script>
</div>
</head>
<body>
<h1>Ruins of Edis</h1>
<section class="project">
<h2>Info</h2>
<div indented>
<p>Project type: Unity Game</p>
<p>Timeframe: 2022</p>
</div>
<h2>Video</h2>
<iframe
src="https://www.youtube.com/embed/9HS_cBV1rOg?mute=1&loop=1&autoplay=1"
class="embed" youtube>
</iframe>
<h2>Product Overview</h2>
<p indented>
A relaxing desert driving game about following a blue light around the ruins of a long lost civilization. Stay within the light or be lost to the desert.
</p>
<h2>Project Overview</h2>
<p indented>
For this project, I was a responsible for the car's controls and physics. I also helped with programming the terrain generation script.
</p>
<h2>Code</h2>
<div indented>
<h3>Controls</h3>
<div indented>
<p>
The drifting system uses a "force angle" which describes the angle relative to the forward direction in which the car should apply force.
This allows the direction while drifting to be changed to be somewhere to the side of the car for it to slide properly.
</p>
<div id="car-update-code" class="code-content code-box">
<script>$(function(){$("#car-update-code").load("https://raw.githubusercontent.com/Sara-G-GD/portfolio-code-highlighting/main/update-car-roe.html");});</script>
</div>
</div>
<h3>Terrain Generator</h3>
<div indented>
<p>
To make the terrain generation extensively configurable, we used a whole collection of stacked animation curves and multipliers.
These were then applied to the result of a perlin noise function to create a heightmap, which can then be applied to one or more terrain objects.
</p>
<div id="terrain-generator-code" class="code-content code-box">
<script>$(function(){$("#terrain-generator-code").load("https://raw.githubusercontent.com/Sara-G-GD/portfolio-code-highlighting/main/terrain-generator-roe.html");});</script>
</div>
</div>
</div>
</section>
</body>
</html>

View file

@ -0,0 +1,73 @@
<!DOCTYPE html>
<html>
<head>
<title>Spirit of Science - Sara Gerretsen</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="../shared/jquery.min.js"></script>
<link rel="stylesheet" href="../shared/style.css">
<div id="site-header">
<script>$(function(){$('#site-header').load("../shared/header.html");});</script>
</div>
</head>
<body>
<h1>Spirit of Science</h1>
<section class="project">
<h2 class="inline">Info</h2>
<div indented>
<p>Project Type: Unity Game for IEGJ</p>
<p>Timeframe: 2022</p>
</div>
<h2>Video</h2>
<iframe
src="https://youtube.com/embed/7Zueiw9SIrI?mute=1&autoplay=1&loop=1"
class="embed" youtube
></iframe>
<iframe
src="https://itch.io/embed/1415379"
class="embed" itch
frameborder="0">
<a href="https://sg-dev.itch.io/spirit-signal-iegj2022">
Spirit Signal by sg_dev, Saltoc, villewilly, jrosenbe, hallo_schoonheid
</a>
</iframe>
<h2>Product Overview</h2>
<p indented>
A top down exploration game setting you to exploring an abandoned factory looking for tools and key-cards while avoiding the unexplained dangers around the place
</p>
<h2>Project Overview</h2>
<p indented>
This was made for the International Educational Game Jam with a team of three artists and two programmers. My role was mainly that of gameplay programmer. I wrote the interaction and movement systems, as well as a few interactions using those systems.
</p>
<h2>Code</h2>
<div indented>
<h3>Interaction</h3>
<div indented>
<p>
When the player clicks, clickable objects near the cursor should be notified that they've been activated. For this, I created an Interactible interface. This interface can then be inherited to clearly mark a component as clickable.
</p>
<div id="interaction-code" class="code-content code-box">
<script>$(function(){$("#interaction-code").load("https://raw.githubusercontent.com/Sara-G-GD/portfolio-code-highlighting/main/iinteractible-ss.html");});</script>
</div>
</div>
<h3>Clicking</h3>
<div indented>
<p>
The player interaction script triggers any IInteractible components within a radius around wherever the player has clicked.
It only does this after ensuring that the clicked object can be reached.
</p>
<div id="clicking-code" class="code-content code-box">
<script>$(function(){$("#clicking-code").load("https://raw.githubusercontent.com/Sara-G-GD/portfolio-code-highlighting/main/interaction-ss.html");});</script>
</div>
</div>
</div>
</section>
</body>
</html>

View file

@ -0,0 +1,38 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="../shared/jquery.min.js"></script>
<link rel="stylesheet" href="../shared/style.css">
<div id="site-header">
<script>$(function(){$("#site-header").load("../shared/header.html");});</script>
</div>
</head>
<body>
<h1>Station to Station</h1>
<section class="project">
<h2>Info</h2>
<div indented>
<p>Project Type: Unreal Engine Management Game</p>
<p>Project Timeframe: Internship during 2022 Jan-Jul</p>
</div>
<p>
A fun, relaxing but still challenging, resource management puzzle game by Galaxy Grove. That I had the chance to work on for an internship of six months.
Being my first "job" working on a real production game, I learned a lot about developing a polished, <i>final</i>, product.
My main contributions were to the dynamic growth of the in-game cities in response to the player's success. I also wrote some internal tooling for generating ambient occlusion maps in bulk using Blender and python.
As well as the decorative birds' behaviour.
</p>
<h2>Steam</h2>
<iframe id="steam embed" src="https://store.steampowered.com/widget/2272400/" frameborder="0" width="646" height="190"></iframe>
<h2>Announcement Trailer</h2>
<iframe
id="youtube embed"
src="https://www.youtube.com/embed/e-FuDjteXxs?mute=1&loop=1&autoplay=1"
class="embed" youtube>
</iframe>
</section>
</body>
</html>

View file

@ -0,0 +1,88 @@
<!DOCTYPE html>
<html>
<head>
<title>Stig Kart 64 - Sara Gerretsen</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="../shared/jquery.min.js"></script>
<link rel="stylesheet" href="../shared/style.css">
<div id="site-header">
<script>$(function(){$('#site-header').load("../shared/header.html");});</script>
</div>
</head>
<body>
<h1>Stig Kart 64</h1>
<section class="project">
<h2>Info</h2>
<div indented>
<p>Project type: Unity Game</p>
<p>Timeframe: 2022</p>
</div>
<h2>Video</h2>
<iframe
src="https://www.youtube.com/embed/0gehGW9LS58?mute=1&autoplay=1"
class="embed" youtube
></iframe>
<iframe
src="https://itch.io/embed/1372223"
width="552" height="167"
class="embed" itch
frameborder="0">
<a href="https://aafke.itch.io/bottom-gear-stig">
Bottom Gear - Stig Kart 64 by Aafke van roon, Jeroeno_Boy, sg_dev, Chirp77, Jyce
</a>
</iframe>
<h2>Product Overview</h2>
<p indented>
A fast paced kart racer about timing your drifts and boosts just right. Play against your friends in splitscreen or the AI in singleplayer and try to get the quickest time.
</p>
<h2>Project Overview</h2>
<p indented>
The game was made by a team of six people over two weeks. I spent most of that working on the input and kart physics. After the time trial mode was done, I also worked on the AI.
</p>
<h2>Code</h2>
<div indented>
<h3>Steering</h3>
<div indented>
<p>
For steering we had some very specific requirements. While drifting, the player needed to be able to control their direction, without being able to flip the direction of the drift or 'drift' straight forward.
When drifting, the UpdateSteering function will transform the current steering input so that, if the drift was started while steering left, the possible range of steering values is within the range of -1 to -min, where min is a positive number lower than one which signifies the minimum amount of steering. When the drift is started while steering right, the range would be opposite, ranging from min to one.
</p>
<div id="update-steering" class="code-content code-box">
<script>$(function(){$('#update-steering').load("https://raw.githubusercontent.com/Sara-G-GD/portfolio-code-highlighting/main/update-steering-sk64.html");});</script>
</div>
</div>
<h3>Basic AI</h3>
<div indented>
<p>
After we had completed the basic time trial mode, we still had about a week to add more features. So while another programmer went ahead to implement splitscreen, I wanted to try and get AI working. The player input component was already separate from the kart physics part. So the basic steering AI works by steering until it is aiming at the next invisible checkpoint on the course.
</p>
<div id="aim-at-target" class="code-content code-box">
<script>$(function(){$("#aim-at-target").load("https://raw.githubusercontent.com/Sara-G-GD/portfolio-code-highlighting/main/rotate-to-target-sk64.html");});</script>
</div>
</div>
<h3>Expanded AI</h3>
<div indented>
<p>
Allowing the AI to drift required it turning into the next turn rather than just aiming at the next checkpoint.
To do this, i first get the next three checkpoints to calculate the total angle of the next turn. This angle is then used to decide whether to drift or not.
After figuring out whether to drift or not, the AI will modify its physics in the same way as when the players presses the drift button.
With the drift started, the AI needs to aim at the checkpoint after the next to drift.
</p>
<div id="update-target" class="code-content code-box">
<script>$(function(){$('#update-target').load("https://raw.githubusercontent.com/Sara-G-GD/portfolio-code-highlighting/main/update-target-sk64.html");});</script>
</div>
</div>
</div>
</section>
</body>
</html>