Math Defense or so

Latest File: Math Defense.wick (151.3 KB)


Summary for changes:
:white_check_mark: Added in animation for enemies
:white_check_mark: Replaced enemies’ previous health text display with health bars
:white_check_mark: Added in new weapon: Mine
:white_check_mark: Changed FPS from 60 down to 30
:white_check_mark: Adjusted most numbers & equations to work with the new FPS setting
:heavy_minus_sign: Needed to move answer text outside menu since shop got larger (temporary?)

I also added a small extra detail to the mine: they damage not one but all enemies within range when exploding. It’s not easy to get, but if you solve the math equation exactly when 2 enemies are on the mine, they’ll all get die, unless if an enemy has enough hp to survive (hp>3).

3 Likes

I can’t see it until night, but the mine behavior should be to be set before the enemies are on the mine. Is that still on place?

Yep, once you answer the equation for the mine, it activates, even if there are no enemies on it.
If activated, it’ll only explode once touched by an enemy, then deactivates after that. Once deactivated, it won’t activate again until the level ends. Every new level, the mine resets.

1 Like

I have tried to export the HTML to play it full screen in my PC, but the currency remains in zero when the game starts.

Whoops, I just found the issue–
When I added the mine on the road, the mine clip was going over the enemies, so I moved the enemies in the top layer to fix that. However, by changing the layer the clip was on, the order that the code was run in changed slightly (top clips run before lower ones), which led to the project trying to use a variable before it was defined in another script.

Thanks for pointing that out, here’s a fixed version: Math Defense.wick (151.2 KB)

2 Likes

Game Assets Refresher soon! Here is a sneak peek… (I haven’t finished, give me a day or so…)

3 Likes

I’m still working with some of the sprites, once they are ready I’ll send you all of them in a separate wick file so you can integrate it into the game. I’ll also work in some animations as well. Meanwhile, @Hamzah_Alani, you can work on these new shop items.

Time Hourglass:

  • Math Operator: Division
  • Enemy Damage: None
  • Cost: $1
  • Behavior:
    ** It is disable until the user solve the division problem.
    ** Once activated, It will stop Enemy movement in the entire map for 3 seconds or so (This could change later)

Hearts: (This will be replacing the current random heart mechanic that we have in place right now.)

  • Math Operator: Random between the 4 ( + - * / )
  • Cost: $1
  • Behavior:
    ** Depending on how many you put at the map, it would appear on the map after you take a hit.
    ** Example: if you buy 2, by dragging them into a map, they will be disable at the beginning until you take a hit. When the user takes a hit, the first heart would be enabled with a math problem. If the problem is solved, then the heart disappears and the user recover the heart at the energy UI. Then, one disabled heart is left, when the user takes a second hit, then the second heart will be activated with the math problem and so on…
2 Likes

Are you using another software to draw those?

2 Likes

The hourglass ability sounds nice!
Take as much time as you need with the sprites :+1:

I’ll start working on adding in the hourglass and updating the hearts item tomorrow, I probably won’t get them done as quickly as the previous updates though, maybe 2 days or so. Also, since the position of the shop is expected to change, I’ll try to make some edits to the last file I shared to prepare for that. I also prevented the user from placing items under the shop, should we keep that, or should we allow the user to place items anywhere in the map, even under the UI?

With all of these great abilities, I find the addition tank a bit useless (especially since multiplication tank deals double damage), so I was thinking if we should “lock” some items in the shop, and have them unlock after the user reaches a specific level? For example, the multiplication tank unlocks after level 3 is completed, the hearts is after level 5, mines after level 7, hourglass after level 10, etc… (this is just an example)

This will not only force the users to start with the weaker tank and rise up from there, but it’ll also give them something to aim for, a goal. With that goal in mind, they’ll have to come up with a strategy for how they want to pass the level with the tools they have while saving for the other unlocked tools.

I also feel like with the hourglass and hearts ability, if someone was to place too many of them over the map, then the game becomes too easy. I’d like to suggest putting a limit somewhere here… for example, the hourglass would have two equations, or you could only buy 4 hearts max, or something like that.

Edit: Maybe we could even limit how many of each item could be bought based on the level… for example, you could buy 2 hearts max after level 5, and unlock more hearts in the shop every 5 levels (this is just an example). Same thing for hourglass and other items.

Also, just to make sure, would you like the hourglass ability to be something that you can place on the map?

Sorry for asking too many questions :sweat_smile:

1 Like

Affinity Designer 2.0

1 Like

I’ll answer in a bit. Im from my cel, and I cant write.much.

1 Like

Everywhere, but not below UI.

Yup, that is the idea, initially we develop everything, then we do the level design. That part is still not designed. Also, I have plan for enemies to be different in behavior, but we can add those details later.

Also, do you still have code to do different paths? I’ll also provide 2 to 3 more tile sets so we can change the scenes as you see in mario games. Example, first 3 levels could use these green tiles, then the next levels could use desert tileset, then ice tileset and so on… and for those we could design different enemy paths.

Well, in theory, do addition operation is easier than doing multiplication, so that is why it damage is only one… also to balance that, the price is cheaper.

Yes, and also, by putting or introducing one tank at a time per level, it is better so people can learn how the game and tanks work.

Well, we will balance that when we do the level design, since the currency (money) would not be infinite. So they are forced to choose between aggressive or defensive.

Yes, also the hearts. (In green space)

2 Likes

Maybe in the future we could do similar games in 3D… haha, but I just experimenting with this so I can do some kind of game title, but not as realistic as this one…

3 Likes

This took longer than it usually takes me since I started my summer courses, and I also had an annoying bug that lasted for some time, I ended up rewriting my code for that part this morning- and it all works now.

I’d advise trying the wick file in the test editor.
It should still work in the regular editor, but there are some things that won’t work there (ex: in test editor, you can’t place tanks/ items over UI but you can in regular editor).

I’ve also added in the heart & hourglass items, and adjusted the UI to match the one in your design.

Also, in the outside right (only visible in editor) I added a text for testing purposes which displays tick, freeze, and time frozen, to help show how long the hourglass “freezing time” effect lasts for.

Here’s the Wick file:
Math Defense.wick (157.8 KB)

Yep, I still have that code (“Game” layer => frame 1 => default script) so adding this in should be easy.


Changing the enemy path when tanks are already placed though might result in having the road go over the tanks, so should every time the map changes, the tanks get removed as well? (and player gets coins for how much the tanks were worth?)

1 Like

Ok, tomorrow Ill give you the sprites, at least what I got until now. Then, we can put this on the side until July, since I will not have access to the forums after some point next week until July.

1 Like

Here is so far…
You can press play and see the animations…

NewSprites6-14-2023_22-02-44.wick (291.7 KB)

1 Like

I tried to add in the assets:

I changed the first few levels as well to make them a bit easier and to help introduce the enemy types one at a time. I also cleaned the code a bit in some spaces…

On a side note, I was impressed when I realized that I was able to replace this equation

Math.ceil((tick/project.framerate)/s)*s===Math.floor((tick/project.framerate)/s)*s

with just

tick/project.framerate%s===0

And, as planned, I made items unlocked in the shop after a certain level is completed.
For now, here’s what I set these levels to:

Completing level 3: Multiplication tank
Completing level 5: Road Mine
Completing level 7: Hearts
Completing level 10: Hourglass

Also, I wasn’t sure if there was any special font I needed to use for the text clips with the new assets, so I kept them in anton.
Math Defense.wick (398.1 KB)

After adding in the image files and coding everything, I felt like there was a difference in the FPS as the levels went on and you added in more items to the map.
I’ve added in an FPS counter to test this out, you should be able to see it on the outside right side. I’d like to know what FPS this project works at on your devices when you guys have time to check this out.

1 Like

It ran ok here…

The progress has been great! You are a great programmer. It has been fun working with you guys in this project!
Later on July I’ll continue adding more details, feedback and sounds.

1 Like

I know why that could be happening… I have noticed for wick editor that it is better (performance and memory wise) to clone individual clips when needed, rather than have a super clip with all the subclips inside.

Example:
You have a clip that contains all tanks… every time that you clone a multiplication one, you are cloning all of them at the same time in memory, but you don’t need all of them because a mult tank will not be converted into other tank in run time.

1 Like

You’re right, this is slowing down the project. I tried dealing with this by deleting all frames of the clones’ timeline that aren’t in perspective (for the tanks and the enemies), and I deployed around 30 enemies to test; the FPS was at a faster rate with the unnecessary frames deleted. I added a function for deleting unused frames in the main project’s “Game” layer’s first frame’s default script:

I could try to also separate the tanks and enemies into 9 different clips and add them in a different frame, and bring them in when needed- though Idk if that’ll make much of a difference.

Math Defense.wick (398.2 KB)

This collab feels almost complete or maybe we’ve been moving fast :thinking: It definitely helped that one person managed the code, in recent collabs I’ve been in (like Forum Fighters) the code always got complicated because you’d have multiple people with different types of thinking working on it.

There are a few things that we’ll still need to decide at some point:

  • Level set-ups
  • What happens when the hearts run out
  • Starting menu (optional)
  • Earnings per level completion (current value: " Math.ceil(level/2) " )
  • How-to-play tutorial

(You don’t need to reply to this now, think of this as a checklist)

Sounds good :+1: Take your time with that, and lemme know if you’ll need help with any of it :four_leaf_clover:

2 Likes