[game/class] Tower Defense example

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
Spawnova
Posts: 557
Joined: 08 Jul 2015, 00:12
Contact:

[game/class] Tower Defense example

Post by Spawnova » 27 Feb 2023, 05:24

I have a class designed for creating simple games with ahk using direct2d and recently wanted to update it, so I also quickly created a tower defense example and though it would be fun to share here as well!
It is not a full game but rather a small example to show class usage, as such some things unique to tower defense style games will not be present

The class and code for this example can be found on the github page here -> Game Class

You may also find my other 2 classes, Image/Pixel Scanning and Overlay Class useful as well =)

Image

robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: [game/class] Tower Defense example

Post by robodesign » 27 Feb 2023, 09:13

This is amazing! Thank you for sharing this!!
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.

User avatar
FanaticGuru
Posts: 1908
Joined: 30 Sep 2013, 22:25

Re: [game/class] Tower Defense example

Post by FanaticGuru » 28 Feb 2023, 18:15

What you do with graphics in AHK is impressive.

I always enjoy your AHK code and videos. The more the better!

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks

User avatar
SpeedMaster
Posts: 494
Joined: 12 Nov 2016, 16:09

Re: [game/class] Tower Defense example

Post by SpeedMaster » 02 Mar 2023, 02:32

The game works very well (Win 7 & 10). :thumbup:
Thanks for sharing. 8-)

User avatar
Spawnova
Posts: 557
Joined: 08 Jul 2015, 00:12
Contact:

Re: [game/class] Tower Defense example

Post by Spawnova » 02 Mar 2023, 06:23

Glad you guys find it interesting =P

Thanks for the feedback @SpeedMaster, always nice to know that it's working as intended, especially since I didn't have a windows 7 machine to ever test the class on. :D

User avatar
elModo7
Posts: 217
Joined: 01 Sep 2017, 02:38
Location: Spain
Contact:

Re: [game/class] Tower Defense example

Post by elModo7 » 02 Mar 2023, 06:25

+1 to every comment so far, impressive work!

robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: [game/class] Tower Defense example

Post by robodesign » 03 Mar 2023, 15:07

@Spawnova : How do you obtain the vTable numbers for the D2D method interfaces? Do you look in .h files or?

I would be interested in extending the overlay class with more tools.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.

User avatar
Spawnova
Posts: 557
Joined: 08 Jul 2015, 00:12
Contact:

Re: [game/class] Tower Defense example

Post by Spawnova » 03 Mar 2023, 17:44

robodesign wrote:
03 Mar 2023, 15:07
@Spawnova : How do you obtain the vTable numbers for the D2D method interfaces? Do you look in .h files or?

I would be interested in extending the overlay class with more tools.
Correct! I look in the .h files to get their index and params, it is hard to add some stuff though because I want to keep it as user friendly as possible and certain things require specific setups so it takes some extra thought in how to achieve something but still have it be somewhat intuitive to use =P

User avatar
FanaticGuru
Posts: 1908
Joined: 30 Sep 2013, 22:25

Re: [game/class] Tower Defense example

Post by FanaticGuru » 03 Mar 2023, 19:03

Did you code a tool to create the cracked rock track? It would be cool to attempt to automate that tool to attempt to generate random level backgrounds if you used code to generate it.

Also, did you ever post the code for you platformer demo: https://www.youtube.com/watch?v=IxSKNPaMb7s&t=145s
That would be great to see.

You got several demos that are right on the verge of being full fletch games. But I get it, once you figure out the interesting stuff the easy stuff to polish it into a complete game is not as interesting. I mean to turn this into a full game is pretty much just a dozen more towers, a dozen more enemies, and a 100 levels. With some campaign elements. But all that is somewhat repetitive to code. Making a random level generator could be interesting though.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks

User avatar
Spawnova
Posts: 557
Joined: 08 Jul 2015, 00:12
Contact:

Re: [game/class] Tower Defense example

Post by Spawnova » 04 Mar 2023, 08:23

@FanaticGuru I used gimp to create everything, although implementing a track editor wouldn't be too hard, but you are right I generally like to learn a bunch of stuff rather than commit to making a full experience.

I never released source on the older stuff because the way it was coded was not very intuitive, messy and hard to follow (I never use comments in my own personal code XD)

But that's why the only 3 classes I made public I try very hard to make sure it's easy for people to understand and use, and I plan to keep expanding on them as I learn new things, it's pretty fun =P

User avatar
FanaticGuru
Posts: 1908
Joined: 30 Sep 2013, 22:25

Re: [game/class] Tower Defense example

Post by FanaticGuru » 04 Mar 2023, 21:32

Spawnova wrote:
04 Mar 2023, 08:23
But that's why the only 3 classes I made public I try very hard to make sure it's easy for people to understand and use, and I plan to keep expanding on them as I learn new things, it's pretty fun =P

I have played around with your 3 classes on GitHub and they are pretty easy to use. An average user can get a lot of effect with little knowledge. The classes take care of all the rendering complexity and the user is left with mostly just what I would call clever math to design good looking effects. Like your rain demo, a little math and boom, nice rain effect.

On several of the examples though, you had the 'overlay' defined as 'clickThrough' which made it difficult to make the window active, which caused none of the hotkeys or dragging to work.

Also, nice to see the Game class converted to v2, hopefully you will convert the Overlay and Scan to v2 also.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks

User avatar
Spawnova
Posts: 557
Joined: 08 Jul 2015, 00:12
Contact:

Re: [game/class] Tower Defense example

Post by Spawnova » 05 Mar 2023, 11:33

FanaticGuru wrote:
04 Mar 2023, 21:32
On several of the examples though, you had the 'overlay' defined as 'clickThrough' which made it difficult to make the window active, which caused none of the hotkeys or dragging to work.
Oh thanks for that, I changed around the initial params sometime after making those early examples and forgot to update them there :oops:

The other 2 classes will be converted to v2 as well pretty soon here, I'm still learning the new syntax myself =P

Post Reply

Return to “Scripts and Functions (v1)”