Hey Fellas! Welcome Back to Another Mini Micro Tutorial by Selfish_Dev!
In my previous blogs, we covered:
So, what’s next? Bringing sprites from the web!
In this tutorial, I'll show you how to render a sprite directly from the web in Mini Micro. This is super useful if you want to dynamically load images instead of bundling them with your project.
So lets get started
Before We Get Started
So guys, I have some important—and unfortunately, sad—news to share. A few days ago, I sent my laptop to a repair shop, and after getting it back, I started noticing some unexpected behavior. At first, I ignored it, thinking it was just due to the fact that my laptop is from 2011. I assumed all the issues were just because of its age.
But then, about a week later, my laptop's OS corrupted for the fifth time—and this time, it refused to install any OS at all. Frustrated, I decided to open it up myself, and that's when I made a shocking discovery... The repair guy had stolen my SSD.
Right now, I'm writing this post and uploading videos using a CachyOS live session. So, if my uploads or posts are delayed, this is the reason. But don’t worry—I’m not stopping.
Because as a wise man once said:
Don't say 'WHY ME?' Say 'TRY ME!💪🔥
It's all part of God's plan—He tests His strongest warriors. ⚔️✨
How to load a sprite from web
Before rendering a sprite from the web, it's essential to understand how to load a sprite from local storage.
I've already covered this in detail in my post [How to Render a Sprite], but for a quick refresher, I'll give you a brief overview in this blog.
clear
grandpa = new Sprite
grandpa.image = file.loadImage("/usr/Grandpa1.png")
display(4).sprites.push grandpa
grandpa.x = 480; grandpa.y = 100
grandpa.scale = 5
Breaking Down the Code
Clearing the Display – Before rendering anything, we start by clearing the display using
clear
. This ensures there's no leftover content from previous displays.Creating the Sprite – We define a new sprite object and name it grandpa. This sprite will act as a container for our image.
Loading the Image – Using
file.loadImage("/usr/Grandpa1.png")
, we load an image from our local storage. The image file is namedGrandpa1.png
, stored inside the/usr/
directory.Displaying the Sprite – The sprite needs to be added to the display. We push it to
display(4).sprites
, which ensures it's rendered on the screen.Positioning and Scaling – The sprite's default position may not be ideal, so we manually set its coordinates to
x = 480, y = 100
. Additionally, since the image was originally 16×16 pixels (which is quite small), we scale it up by a factor of 5 to make it clearly visible.
This is a fundamental method for rendering sprites in MiniScript. Now that you know how to load an image from local storage, the next step is learning how to load one directly from the web!
Loading Image from Web
Now that you know how to load a sprite from local storage, loading one from the web becomes a piece of cake! (Dont get to hungry its learning time)
Instead of using file.loadImage
, we use the http.get
command, which fetches data from a given URL. With this, we can easily load and render sprites directly from the web.
Here is a working example
clear
mini_script = new Sprite
mini_script.image = http.get("https://miniscript.org/img/Icon.png")
mini_script.x = 480
mini_script.y = 320
display(4).sprites.push mini_script
(This example is taken from the official MiniScript Wiki.)
Here command http.get
is used instead of file.loadImage
Now some may ask what http.get
even does
This command basically returns the content of the url
This supports text , image , sound , and raw binary data