JR 01's Monthly Coding Challenge 2025

I’m sure you could use any sort of currency in a game. Coins are usually the most common.

2 Likes

I still have no idea what I’m doing

Beginner Challenge
Intermediate Challenge

Sorry don’t feel like really doing this one and I’m short on time atm.

Basically just get the average between the X, then the Y. Now just add half of the screen size, something like that. I might update this later tonight after I get back, but I’ll probably forget about it lol

Expert Challenge

I’ll admit it, I know that this existed, but I forgot the formatting so I check your old example to remember it

3 Likes
Beginner

Intermediate

Oh… this is where my limited IQ fails me.

The expert challenege is technically correct but isnt the answer I was looking for. The challenge in general is “what is a better method than stacking a ton of if statments”. I should’ve added that it needs to evaluate math too.

1 Like

Close, but the number wouldnt reset to what is was if you die and restart the level.

Oh. But does it have to reset to the number the player had when they started the level, or just all the way to 0?

1 Like

To what the player had when first started the level.

Oh mann. WHY is this beginner.

You just need a couple more behaviors, its beginner because it just needs a few more steps to what most beginners make. Its a learning process and to help make a better coin system for anyone who has one in their games.

1 Like

Not sure if this is the intended solution, but something like this is very easy to setup if you’re aware of it.

My Expert Challenge Solution

Switch cases are typically the best way to address using multiple if statements. They’re easier to read, write, and compute.

Switches check a value to see if it is equal to any case. The problem is that checking the expression variable wouldn’t be that useful since we’d have to account for every number in a range. (Imagine typing out a case for every number that “A” could be for everything less than 100. Hint: It’s not possible!) Pivoting our approach a little by using a Boolean check, we can see any time the imported variable is true and output accordingly.

image

The above code when pasted into an expression will output 1 when A is above 100, 2 when A is below it, and 3 when it is equal to it. These numbers and relations could be changed to whatever variables you needed to check and however you needed to check them.

5 Likes

January Challenge Answer

@CodeAlpaca @JUSTPLAINOP @Recryptech

Answers

Beginner Challenge: Coin Counter

A coin counter that resets on level restart, but saves on level progression.

Intermediate Challenge: 2 Subject Camera

This can be done 2 ways with the player (game world) and Mouse (UI) or with the player (game world) and another object like a goal or obective (game world).

Here’s a solution with the player and mouse:

And here's a solution with 2 game world objects:

Expression Challenge: No If Statements

So a better way to not only to organize your code, but also to optimize it is by using Switch cases. A switch case is like a list of options that is chosen by the value that goes in. A list like @CodeAlpaca solution is correct by technicality but it is not the most optimized because ALL the properties of a list is loaded into memory. This is also true for if statements, where both True and False statements can load of list of other statements when it could simply be loaded much quicker.

switch (A-1) {
     case 0: A+B;
     case 1: A-B;
     case 2: A;
     case 3: B;
     default: 0;
}
4 Likes

wow that is quite a bit of code.

1 Like

Really interesting
I love this series

4 Likes

honestly same.

2 Likes

2025 Monthly Challenge - February

Rules:

  • Do not use my code or my examples, I will know and will make adjustments to the challenge.

  • If you already have the code for the challenge, I request to make it from scratch.

  • The answer can be a game link or a screenshot (Win+Shift+S).

  • When posting an answer, please use the Hide Details function (in the gear icon).

      • [details="Answer"] Paste you answer here [/details]

Beginner Challenge:

“Point and Shoot”

Share a screenshot on how to make an object emit a bullet at the mouse cursor.

image

Intermediate Challenge:

“Staying on a Platform”

Using raycast behaviors, share a screenshot on how to make an enemy move and turn around whenever they approach the edge of the platform or ground they are walking on.

image

Expert Challenge:

“Calculate Zoom between 2 Objects”

Using the positions of 2 objects, calculate the zoom of the camera needed to keep them on screen. The camera should also stay between them too like a 2 subject camera, but that was done last months challenge and this challenge is only wanting the code and math needed to calculate the zoom.

image

Expression Challenge:

“Extracting Digits”

Using Haxe, extract the number 7 from 37469.
This should be done without math.

image

3 Likes