diff --git a/.vscode/settings.json b/.vscode/settings.json index fd81e19..2317900 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,3 @@ { - "Lua.runtime.path": [ - "?.lua" - ], "Lua.runtime.version": "Lua 5.1" } \ No newline at end of file diff --git a/MANUAL.md b/MANUAL.md index 83610df..1912925 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -32,8 +32,6 @@ Uranium Template originally formed during the creation of a currently unreleased - [Default callbacks](#default-callbacks) - [`uranium.update(dt: number)`](#uraniumupdatedt-number) - [`uranium.init()`](#uraniuminit) - - [`uranium.press(direction: string)`](#uraniumpressdirection-string) - - [`uranium.release(direction: string)`](#uraniumreleasedirection-string) - [Custom callbacks](#custom-callbacks) - [Requiring files](#requiring-files) - [Standard library](#standard-library) @@ -76,6 +74,8 @@ Uranium Template originally formed during the creation of a currently unreleased - [`easable:reset(new: number): void`](#easableresetnew-number-void) - [Operations](#operations-2) - [`input`](#input) + - [`uranium.press(direction: string)`](#uraniumpressdirection-string) + - [`uranium.release(direction: string)`](#uraniumreleasedirection-string) - [A note about keyboard inputs](#a-note-about-keyboard-inputs) - [`bitop`](#bitop) - [`scheduler`](#scheduler) @@ -96,6 +96,7 @@ Uranium Template originally formed during the creation of a currently unreleased - [`ease`](#ease) - [`util`](#util) - [`aft`](#aft) + - [`noautplay`](#noautplay) - [`uwuify`](#uwuify) - [Examples](#examples) - [Default Uranium Template code](#default-uranium-template-code) @@ -270,12 +271,6 @@ Called every frame. `dt` is the time passed since the last frame, the "deltatime #### `uranium.init()` Called once on `OnCommand`. Every actor has been created, and the game should be starting shortly. -#### `uranium.press(direction: string)` -Called when the player presses on a certain key. **Currently only supports arrow keys!!** `direction` can be `Left`, `Down`, `Up` or `Right` (TODO: change this to an enum). - -#### `uranium.release(direction: string)` -Same as [`uranium.press`](#uraniumpressdirection-string), except for releasing a key. - ### Custom callbacks Custom callbacks require no extra setup. Define your callback like usual: @@ -591,6 +586,12 @@ directions = { } ``` +#### `uranium.press(direction: string)` +Called when the player presses on a certain key. **Currently only supports arrow keys!!** `direction` can be `Left`, `Down`, `Up` or `Right` (TODO: change this to an enum). + +#### `uranium.release(direction: string)` +Same as [`uranium.press`](#uraniumpressdirection-string), except for releasing a key. + #### A note about keyboard inputs Working with left/down/up/right inputs can be tiring at times and it's hard to always fit designs to work with them. However, if you're willing to take a little compromise, you can also _access all keyboard inputs_. However, it's worth noting that this **depends on NotITG's Simply Love** (any forks will work fine too) both for your development environment and for all players. That being said, if you want to access the keyboard API, this is how you do it: @@ -726,6 +727,14 @@ aft:addcommand('Init', function(self) end) ``` +### `noautplay` + +A single function which can be called before `uranium.ready()` to disable autoplay for the duration of the file if the player has it on. + +```lua +require('stdlib.noautoplay')() +``` + ### `uwuify` ```lua diff --git a/src/main.lua b/src/main.lua index 1566353..5a914a9 100644 --- a/src/main.lua +++ b/src/main.lua @@ -1,43 +1,50 @@ -local aftSetup = require('stdlib.aft') require('stdlib.color') -require('stdlib.vector2D') -local coverQuad = Quad() -coverQuad:diffuse(0, 0, 0, 1) -coverQuad:xywh(scx, scy, sw, sh) +-- define a basic quad +local quad = Quad() +quad:xy(scx, scy) +quad:zoom(120) +quad:diffuse(0.8, 1, 0.7, 1) +quad:skewx(0.2) -local testQuad = Quad() -testQuad:zoom(50) +-- define a sprite +local sprite = Sprite('docs/uranium.png') +sprite:xy(scx, scy) +sprite:zoom(0.4) +sprite:glow(1, 1, 1, 0) -local aft = ActorFrameTexture() - -local aftSprite = Sprite() -aftSetup.sprite(aftSprite) -aftSprite:diffusealpha(0.99) -aftSprite:zoom(1.01) -aftSprite:rotationz(0.2) - -aft:addcommand('Init', function(self) - aftSetup.aft(aft) -- put this here; else it'll recreate it every frame! - aftSprite:SetTexture(self:GetTexture()) -end) - -local text = BitmapText('common', 'uranium template!') -text:xy(scx, scy) +-- let's add some text aswell +local text = BitmapText('common', 'hello, uranium template!') +text:xy(scx, scy + 100) +-- update gets called every frame +-- dt here refers to deltatime - the time that has passed since the last frame! function uranium.update(dt) - coverQuad:Draw() + -- let's rotate our quad + quad:rotationz(t * 80) + -- then shove it to the screen - similar to a drawfunction! + quad:Draw() + -- and you can do this multiple times of course! + quad:zoomto(180, 180) + quad:rotationz(t * 100) + quad:diffusealpha(0.4) + quad:skewx(0.1) + quad:Draw() + -- no need to reset properties - uranium resets all properties that you set upon definition! - aftSprite:Draw() - - local rainbow = shsv(t * 1.2, 0.5, 1) - - testQuad:xy((vectorFromAngle(t * 160, 100) + vector(scx, scy)):unpack()) - testQuad:diffuse(rainbow:unpack()) - testQuad:zoom(50 * math.random()) - testQuad:Draw() - - aft:Draw() + -- throw in the logo aswell, because why not + -- zoom and glow is done for a quick-and-dirty outline + sprite:zoom(sprite:GetZoom() * 1.1) + sprite:glow(1, 1, 1, 1) + sprite:Draw() + -- if you can't wait until the start of a frame to reset properties, you can manually do it + reset(sprite) + sprite:Draw() + -- for the text, get a rainbow color + local col = shsv(t * 0.6, 0.5, 1) + text:diffuse(col:unpack()) -- the :unpack() is necessary when passing into :diffuse() + -- wag the text + text:rotationz(math.sin(t * 2) * 10) text:Draw() end \ No newline at end of file