Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Creating a Project Template to "jump start" development of 2D action games

Author
Message
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 25th Mar 2018 02:47 Edited at: 25th Mar 2018 03:06
A year or so ago I remember posting that I was thinking of making a Game Jam Template. And while I did work on that a bit I never completed it or posted any code for it. It was summer and I pretty much just stopped all development.

Anyway, I have been thinking about making another 2D game for release. An actual real game I mean instead of demo stuff.

I decided before I do that to spend some time creating a project template to "jump start" development of 2D games. Reason I am posting is because I thought I'd share this when complete and possibly as I develop it. However, I know most of us all develop differently so am not sure how much value there would be in me sharing this.

What I am going for with this project is there is so much boiler plate style code in a given type of game that really can be done one time at least as far as getting all of the structure implemented and so forth. And then a developer can just change the details to get a quicker start.

I think the best way to do this kind of thing is to focus on a given game type. 2D is too broad. That could be board / puzzle games, mobile swiping games, etc.

So what I am interested in building is a template for 2D action games. Games with a Splash Logo, Title Screen, Information Screen, player sprite, enemy sprites, collectible sprites, bullet sprites, explosion sprites and using tile maps.

Basically, a template to build things like non-physics based shmups and platformers and so forth.

However, I think even this may be too broad and perhaps it would be best to make an AppGameKit 2D Shmup Game Template and an AppGameKit 2D Platformer Game Template. I think ideally I'd have a 2D Platformer Game Template and an 2D Shmup Game Template.

Basically, I am just posting to get some discussion going here to see what you all think about it.

It's something I am definitely doing for myself but if we discuss it here and it seems like their is interest in it and also that we all kind of favor a single generic 2D Shmup and Platformer Template OR favor a 2D Shmup Template and a 2D Platformer Template that will he me to decide how to approach it.

Basically any such template will have Main.agc file with GameState logic.

And the project media folder will include some mock-up screens for Title, Info Screens as well as mockup sprite and tile sheets and corresponding sub image files.

Basically it will have these screens (and a screen with the AppGameKit logo that I have not posted here)... keep in mind I scaled these down to 1/4 quarter normal size for posting here.



And the idea is this will all work. The title will work with option navigation and selection allowing Info screen to be displayed, the game to quit and the game to start. So a person can just use this right off the bat. Then whenever they are ready they can make their own Title Screen, Info Screen, etc.

In fact, I already have this done including created different subimage template files that work with different sub image sizes within different image atlases (subimagesFor128x128ImageWith16x16SubImages.png and subimagesFor256x256ImageWith32x32SubImages so far).

Each template will also have an AssetManager to load and release the images and audio content of the various phases of a game.

Then each template would have PlayerManager, CollectibleManager, EnemyManager,, etc files that have functions skeletoned out for Init, Update, their state management and so forth. And of course a CollisionManager again with stubbed out functions such as CollisionsPlayerBulletsHitEnemy(), CollisionsEnemyBulletsHitPlayer(), CollisionsPlayerCollectedItem() (for picking up collectibles) and so forth.

The idea being it covers the base stuff needed by games. The structure would already be there. For me it is an important thing because I want all of this boiler plate done one time. Normally, to get this kind of benefit I just take an older project of mine and use it as the starting point for the new game. BUT what I find with that approach is I have to strip out so much game specific stuff that it takes a lot of time and can make a mess that I then need to clean-up.

Alright that is it. Let me know your thoughts on if this is something people would like me to share here and if you think it would have any value for your and others. Thanks!
TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 26th Mar 2018 04:43 Edited at: 26th Mar 2018 16:32
Okay, so I worked on this and have a solid template in progress for 2D vertical shmup games.

The template has the following implemented:

* Made with AppGameKit logo splash screen fades in, holds a bit, fades out

* Title screen image fades in

* Title screen implemented with options to Start Game, display the Info Screen and exit the game

* Info Screen Fade in, wait for exit key press, fade out back to Title

* AssetManager to load sprite images from atlases into object specific arrays (playerimages, enemyimages, bulletimages, collectibleimages, etc) as well as create a color image for particles and all purpose color image for HUD usage.

* PlayerManager Init(), Update() including state management for Spawning and normal play. Movement and shooting is implemented.

* BulletManager Init(), Spawn(), Update() with state management and an Impact() function that is called by the CollisionManager when a bullet hits something

* EnemyManager Init(), Spawn(), Update() with state management and an ApplyDamage() function that is called by the CollisionManager when an enemy is damaged

* CollisionManager that checks for player bullets hitting an enemy and calls the BulletsImpact() and EnemiesApplyDamage() functions for these objects

* ExplosionManager with Init(), Spawn(), Update with state management for managing AppGameKit Particle System based explosions with ability to specify the size of the particles

Now in practice it is not much of a game at all but that is not the point. My goal here is to just create a template to jumpstart development of a 2D Vertical Shootemup in AGK. So immediately having all of this available is actually quite a time saver. And again since there is very little game specific logic implemented and instead it is mainly all of the boiler plate code we need to write just to get the structure in place to manage all of the images, sprites, states, collisions, and so forth.

The template project comes with the AppGameKit logo screen, the Title Screen, the Info Screen, the sprites atlas image and the sprites subimages text file.
So I can just edit the Title Screen and Info Screen images as I see fit for making an actual game.
I can edit the sprites atlas image to create the player images, enemy images, bullet images, collectible images and so forth.
I can build on to the code implementing the specific game logic.

And when I say "I" can do the above I mean you, whoever can do that. I have put some time into things to simply customizing what is already implemented such as the fades for example if a person wants to change the colors of the fade on the Made With AppGameKit logo, Title, Info and Gameplay it's as easy as editing this to use the colors you want to use...


So at this point when the Template project is run the AppGameKit logo fades in and out, the title appears and...



So hopefully this will help to clarify what I am building here. Just a base project that already has all of the boilerplate code implemented. So a person can immediately start at this point and work on their actual game. Start on the fun bits. The important parts that make one game different from another game.
TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th Mar 2018 18:16
I thought about doing something similar for puzzle games, but I realized I could really only build it for one specific type of game. Puzzles all have their own unique mechanics, it'd be hard to encompass them all in one framework.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 26th Mar 2018 18:57 Edited at: 26th Mar 2018 21:02
@Phaelax that is exactly how I see it. I can certainly make boilerplate code for a general purpose game but the more general purpose it is the less or more it would have in it. Meaning either it would have only the boilerplate code common to all games or would it would need code required for all games. The latter is not a good approach IMO because first as a project it becomes huge and second for end use it means there is this big framework that only a portion would be used for any game type and specific game.

So going genre and even subgenre specific is the way to go although I have been thinking I could create a ShmupTemplate for example that supports vertical and horizontal shmups right from the start by simply including PlayerV.agc and PlayerH.agc code modules and so forth. Then a person would only need to include one or the other and if the game needs both horizontal and vertical stages then include both.

So I think that is how I will proceed with this.

Enemies.agc should be fine as is because this is something that should be implemented for each game. Maybe it is a single screen game with enemies entering screen from above and sides, maybe it is a tilemap based scrolling game with enemies and enemy spawners included in the tilemap data.

I will implement tilemaps sooner or later in it and have this able to support single screen shmups, vertical scrolling shmups and horizontal scrolling shmups "out of the box".

Then I will use it at some point to create a shmup game and anything I run into during that process that can be included in the template will be.

Alright thanks for posting!
TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 26th Mar 2018 19:09 Edited at: 26th Mar 2018 19:11
This is the first time I tried the AppGameKit particle system and I must say it is excellent so easy to use and so flexible. Normally I just implement my own particle system but figured there's should be more efficient being implemented in C.

The ExplosionManager manages 8 particle emitters meaning there can be 8 explosions at any one time on screen which should be more than enough. If that is not enough... increasing the number is as easy as increasing the constant EXPLOSIONS_MAX.
TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)
puzzler2018
User Banned
Posted: 26th Mar 2018 20:05
Really impressive.. love the particles for producing the explosions.

Keep up good work
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 27th Mar 2018 13:34
Quote: "I will implement tilemaps "


That's one thing I actually do have, my Tiled importer. Since it already supports orthogonal and hexagonal maps and several of the map features, it's a great base for building any tile-based game.

What'd I'd like to add is a way to draw paths for enemies to follow at certain intervals during the game. As a vertical (or horizontal) shmup game typically auto-scrolls and thus a definite length of time for the map, having paths triggered at specific time indexes would be easy. If you're familiar with SEUCK from Amiga, that's what I'm thinking.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 27th Mar 2018 14:56 Edited at: 27th Mar 2018 15:20
Yeah enemy paths are easy enough to do right in the tilemaps. I implemented that in my "old school" 3D FPS project. Just define paths in the Path layer in Tiled and then just a matter of scanning that layer pulling out the path data and store it in an easy to use way. The enemies in that old school FPS are roaming around on paths pulled from a layer in the tilemap.

For import I just copy the actual layer data over to a new text file since I don't need anything other than layers and the tiles that are in them. So a plain text file is all that is needed although I did make it so some blank lines and comment lines can be added to the text file. Never really cared for xml. I get what they were going for with it but it is such a heavy format adding so much filler meta data that takes up space.
TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 27th Mar 2018 22:18 Edited at: 27th Mar 2018 22:20
Although... really for something like a shmup I would likely do paths differently. Either just make a utility allowing mouse to draw flight path or building a motion table in code. Just happened to think I should share that because I just did that in my last dev session for one of the two enemies in the template project. Just a simple wave motion that instead of being done programmatically with accel & decel applied to current velocity instead velocity values are pulled from a predefined motion table defined in code.

A draw with mouse Motion designer utility would be simple enough to knock out and include with the template too.
TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 28th Mar 2018 00:57
I never liked XML formats either. It serves no purpose in most file formats because when will you ever edit it textually? Binary format is the best. Easier to implement, faster to load, smaller size.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
nonom
6
Years of Service
User Offline
Joined: 12th Nov 2017
Location: Picking mushrooms
Posted: 28th Mar 2018 03:49 Edited at: 28th Mar 2018 03:51
If you have a few thousands of items, skills, classes definitions, XML is pretty useful to manage the properties into a control version system.
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 28th Mar 2018 04:14 Edited at: 28th Mar 2018 04:16
Okay, added some more stuff to the template. It is a bit challenging to focus on adding what is needed and not think in terms of actually making a game out of it. lol

I updated the graphics because single color cubes truly aren't very interesting. But rounded cubes in 2 different colors now that is much better. Also knocked out a simple player ship image and shaped the player's bullet a little.

As for the actual template functionality... I implemented movement types and have two different kinds implemented. Simple unchanging velocity based movement and motion table based.

The actual motion defined is very simple just a wave pattern used by the slower moving large enemy.

I added hit indicator fx to the enemies, health and lives properties to the player, collision checking between the player and the enemies, hit indicator FX to the player (not very noticeable because crashing in to any enemy destroys the player in 1 hit but will be noticeable when enemies fire and their bullets hit the player), explosion of the player ship, decreasing lives by 1, if player has lives remaining they respawn otherwise that is it.

More boilerplate such as defining 2DVector type and the array of "motion tables".

Basically I am just implementing two examples of each thing as in 2 enemies. 2 different types of motion, etc. The important thing is providing a foundation to build in and using 2 different examples of things should make the pattern clear so people can extend and add say 3, 4 or even 10 more enemies as well as adding several more motion types.

TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 28th Mar 2018 05:18 Edited at: 28th Mar 2018 05:23
Quote: "I never liked XML formats either. It serves no purpose in most file formats because when will you ever edit it textually? Binary format is the best. Easier to implement, faster to load, smaller size."


It's purpose is for files which *will* be read/edited textually, I use it to define my UI for example which allows for very quick and easy set up and modification in any plain old text editor.

It would be far more complicated to work with this in a binary format:



Or for data which needs to conform to a common accepted standard that anything can make use of without needing specialized/unique editors, handling, and knowledge/documentation. (that said, I generally prefer JSON to XML, which is more lightweight and in many languages can parse directly to and from application objects)

Of course specialized formats have their own advantages for specific applications such as load speed and file size, but really there is no objectively 'best' data format. Every situation is different, with different needs and concerns. Each format has advantages and disadvantages which can make them subjectively better or worse for a given purpose.
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 29th Mar 2018 16:11
Last night I worked on this again and created a MotionRecorder allowing a person to draw paths with the mouse and save them to binary data files.

Tonight I will update the template to load motion files and store the data in the motion arrays (remember these are already supported and the large enemy is using a motion only difference is that one was defined in code).
TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 29th Mar 2018 23:21
I guess for small files, xml would be ok. But things like Tiled, which you'll never edit the file outside the editor, exports in xml.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 30th Mar 2018 18:46 Edited at: 30th Mar 2018 19:00
Last night I got the motion data loading so the enemies are riding the paths drawn with mouse. Next thing either tonight or tomorrow will be adding an EnemyWaveManager and that will bring this template to a good spot.
TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 1st Apr 2018 01:49 Edited at: 1st Apr 2018 03:35
Okay just an update here. This Template Project has come along very well.

At the title screen pressing F1 takes you to the Motion Designer which allows you to draw paths with your mouse. Then S saves those. C clears the path data and screen.

I haven't shown any of that. lol But it has how I made a couple of the paths. There are actually only 3 paths total defined but there is a lot of flexibility because the X and Y movement data can be reversed or speed modified easily in code.

For example, the last 4 waves of enemies that appear are all using the same base motion data but due to flipping x and y directions (x=1,y=1, x=-1, y=1, x=1, y=-1, x=-1, y=-1 are the distinct patterns) we end up with what appears to be 4 distinct movement patterns.



So adding on to the list I posted previously now there is a built-in Motion Designer, a Wave Manager that can allocate up to 4 tasks with each handling a different wave spawning enemies at any one time (as usual, if that is not enough just increase ENEMYWAVES_MAXTASKS as needed. The Spawning itself is quite flexible allowing specifying delay of appearance between enemies in the wave and the amount to offset each successive enemy in the x and y direction. Setting delay to 0 means all enemies are instantly spawned and a task is not even allocated for that wave. Otherwise a task processes a wave each frame taking into account delay and so forth and spawning enemies accordingly.

To help clarify this is how the waves are defined in the template..


I think that is all I will do today. I suppose I could add enemy firing but that is super easy to knock out. Still I guess for a true template project it should be included so maybe tomorrow I will add that.

This simple template (remember the purpose of this is just to provide a base template... a starting point... that is it not meant to be a game in itself) has nearly 1 minute of gameplay in it now.

Alright well if this is of interest to anyone yet let me know and I will post the source code.
TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 1st Apr 2018 03:54 Edited at: 1st Apr 2018 03:57
And here is an example of the built-in motion recorder that is accessed via the Title Screen (idea being once people are done designing motions they just comment out that bit of code checking for the key press to go into Motion Recording mode).

Press F1 at Title Screen brings it up.

It automatically changes the screen to be bigger than what the game uses (based on the Title Screen dimensions) and draws a rectangle to define the actual game resolution. This way people can be sure to be able to start their enemies outside the visible play area so they can enter the visible screen by following the path.



Pretty straight forward. In reality it simple connects dots each frame connecting the points between the last position the mouse button was pressed and the current position the button is pressed at.

For this reason one can hold the mouse button and draw freely as shown in the first example in the video or they can move the mouse click the button then move the mouse click a button and the line is generated between those points filling in all motion data points as needed as shown in the second example.

S saves the motion data
C clears the screen and motion data buffer.

And of course Esc returns to the title screen.
TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 2nd Apr 2018 01:50 Edited at: 2nd Apr 2018 02:18
ALRIGHT! The forums are back up! Was going to post this update earlier but for hours forums were down. On the plus side they seem faster now. Like instantaneous.

Anyway... I tweaked the enemy wave spawn parameters so the purplish enemies come out like "space snakes". Tweaked the explosions a bit. And increased the speed of the player bullets significantly while reducing the firing rate slightly.
That stuff is just to make the example be a little more interesting.

The biggest difference is I used the free https://www.bfxr.net/ to create some sound fx and added audio to the template.

I am now almost... kind of... possibly... a tiny bit... considering maybe just making my own pack of AppGameKit game templates and putting it up on Steam.
Knock out a few different templates that can be used as a base to build a few different types of games. BUT... who knows.
I'll play it by ear I guess. Who knows in a week or two I might be ready to take a break from computer for several months.

TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 2nd Apr 2018 14:21
Very cool, you're moving right along. Makes me want to revisit my SEUCK idea.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Amon
9
Years of Service
User Offline
Joined: 30th May 2014
Location: Shropshire, United Kingdom
Posted: 2nd Apr 2018 18:57
This is shaping up very nicely. I'd like to see the screenfade code. I can wait though.
Imaginations' greatest gift is the knowledge you supply it.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 2nd Apr 2018 21:34
I'd like to see how he's storing the motion paths. I see 3-4k points, I can't imagine he's storing an array that large.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 3rd Apr 2018 01:32 Edited at: 3rd Apr 2018 14:34
Nothing fancy here. It is just straightforward iterating through the loop of points and writing integers out for X and Y vectors to a binary file.

I saw no reason to complicate things. There are 2 distinct motions being used in the template so far (and can be seen in the video above). Remember, each motion file can produce 4 different motions in game and this is used to (I think) good effect in the template example.

What I mean by that is say the normal recording is a line traveling straight from the upper left corner to the lower right corner. For simplicity let's assume this is each point having vector data of (1,1) that is move 1pixel right and 1 pixel down for each point.

If an enemy is instead spawned at the bottom left corner of the screen and the ydir modifier set to -1 now each vector will be played as (1,-1) and the enemy will move from lower left to upper right.
The same can be done for the xdir modifier reversing it to -1 and combined with the ydir modifier of 1 and -1 this gives us 2 more motions. Moving from upper right corner to lower left corner and moving from lower right corner to upper left corner.

And of course, the enemies themselves can be spawned wherever a person desires. So with that in mind and considering the actual patterns you draw will be much more complex / interesting than a simple straight line it will be very difficult to notice this is what is going on.

Anyway, the motion files for the two patterns used in the example are 38K and 36K. Remember this is for a game running at 1280 x 720 resolution with the actual motion designer area being 1440 x 880. So the size of the motion data is not a limiting factor. You could easily have a dozen (or more!) of them. And those in turn would expand to become 4 dozen possibile patterns in game.

These file sizes are tiny. Only taking up this much space due to the resolution. For example back on an Amiga the resolution would be about 1/12th so the same patterns would be approximately 3.2K and 3K respectively if stored as 32-bit integers. Of course since that was 16-bit the size would be cut in half giving us data sizes of 1.6K and 1.5K. Ah it is just the difference in technology / resolutions over the past 20+ years.

It may be of interest to note that originally I wanted to just load those "delta" values and have the enemies move as needed as a velocity. However, what happens is due to using framerate independent code things fluctuate and enemies can get out of sync due to these tiny fluctuations. It adds up over time.

Just another big difference we have today compared to machines such as C64 & Amiga where we knew framerate would be same on ALL machines 60 fps or 30 fps (or 50 and 25 for PAL... BTW some of those European PAL-targeted games were damn hard for us NTSC guys... being built to be a challenge over there and then they ran at 20% faster over here lol!). And if framerate dropped well it dropped and nothing changed except the game ran slower for a period of time. Again just the way things have changed.

So ultimately simplicity being the golden rule... the answer is straightforward. When the data is loaded in they are processed and these delta values from point to point are stored internally as running total x and y offsets from a starting location of 0,0.

In this way speed control of enemies on a path becomes unlimited and regardless of framerate micro fluctuations enemies are always all on the path perfectly because they pull the offset for their current frame (point on the path) and add it to the x and y position they started at (which is stored when they spawn). You can almost think of it like a video in a sense that can be fastforwarded, reversed, etc.
TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 3rd Apr 2018 19:04 Edited at: 4th Apr 2018 21:58
I had a go at my own path designer. I didn't implement any timer-based movement, wasn't really needed for my example but would be simple to implement into any existing system. Use left mouse to place points in a sequential order; which isn't exactly drawing a path as fluid as your freehand example, unless you click a lot. Instead of basing movement on a time index, you just update the object's distance along the path. This let's you control speed and acceleration and simplifies the path by making it seem like a linear distance. Another benefit of this is it makes it very easy to precisely space objects apart along the path. The findPoint() function needs optimized still. Since the points are in order, I can change this over to a binary search.

Also, you can calculate the time needed to traverse the path since it stores the overall length of the path, which could be useful information.

I haven't saved the data to a file, so I can't state any filesize claims. My first instinct was to base the position along the path by a time value, 0 to 1, but then realized it would just complicate other things. My code is based off an example I did for following bezier curves at a constant rate.



Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 3rd Apr 2018 19:17 Edited at: 3rd Apr 2018 19:18
That sounds interesting!

It can definitely be done by defining points and saving fixed offsets for those. Long ago I made a motion designer like that in AMOS for a shmup level I created for what was to be a community game project Capn Bubba And The Nasty Alien Menace (which I don't think was ever released but fun on the Amos-List at the time).

And I made a smoothing function for it that would apply curves to the hard angles of the points. It worked very well.

But this current approach works well. Can lay down lines or draw freehand and doesn't matter what the framerate actually is. And it is very fast processing.
TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 3rd Apr 2018 22:01
Quote: "And I made a smoothing function for it that would apply curves to the hard angles of the points. It worked very well."

That was next on my list to look at. What kind of method did you use? I was think either some kind of cubic spline, or just average out neighboring points.

I was also considering skipping the majority of the level design work in the app, and just importing a Tiled map. Seems pointless to build an editor when a good one already exists. Then from the app, you set the scroll rate and other parameters and can start placing paths and selecting enemy ships.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 3rd Apr 2018 22:26 Edited at: 3rd Apr 2018 22:29
Just averaging the angles of the lines coming into the points. Basically pushing part of the angle change back on both sides of the point creating a curve at and around the point. I think it just did 2 or 3 passes of that best as I can remember. It was a long time ago now. I might have even done that part later on my personal version 2. At the time Giark was always cracking the whip so to speak for eveyone to hurry up and submit their levels.
TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 4th Apr 2018 04:54
I worked on this tonight to add enemy firing and then started on one state based (basically AI) enemy. Although I created a motion designer and pattern-based enemies I've always been more interested in AI / state-based enemies. But since I always do state-based and because predefined patterns look cool and most shmups have them it was definitely worth adding it.

I am wanting to wrap this up soon. Kind of thinking I'd like to make a game again. Tomorrow I can finish this new enemy and decided I won't bother with tile maps. I mean it is a template just a foundation starter not meant to have everything under the sun in it.
TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 4th Apr 2018 20:33
You might this useful for your project, pixel-perfect collision.

https://forum.thegamecreators.com/thread/219444

If you care to know the development history: https://forum.thegamecreators.com/thread/219346
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 5th Apr 2018 01:53 Edited at: 5th Apr 2018 01:54
I added enemy firing. Completed the new AI/ State-based enemy. And decided I should add a basic HUD showing health and reserve ships so did that too.

I think this is basically done.

TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 5th Apr 2018 19:08
That's pretty sweet. All you need is some fancy graphics
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 5th Apr 2018 20:17 Edited at: 5th Apr 2018 20:20
Thanks. No fancy graphics needed for this. Just a template. People can use whatever graphics they want. I just focused on the programming so folks can have a "jump start".

Open the project and start working and they will already have all of this done. Just remake the Title and image screens, replace the sprites sheet, replace sounds, record their own motions, define waves etc.

Just add more and finish the game but the state management and a lot of core functionality is already done. It even supports desktop, mobile (well Android anyway) and web exports. Supports keyboard, controller, virtual controls etc.
TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 7th Apr 2018 17:12
So I added some actual sprites to my path and tried to get the ships to point in the direction of the path but I can't get it stable. Have you done this yet? I thought I could just use atanfull using the two points a ship lies between to figure the angle, but I think the points are too close together to get a stable result. Precision problem maybe? The ships spin back and forth a lot. Then I tried use the old position and new position to determine the angle of direction and that's jittery as well. Making them faster smooths it out a bit, so I think it's just the sample size between points for atanfull is too small.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 7th Apr 2018 18:41 Edited at: 7th Apr 2018 18:43
No I haven't bothered with it for this template I figured that would be the kind of thing each person could decide to do or not because it would be good for some games but not others. Like smiley faces, spiky ball critters and such would have no need to rotate based on movement and actual spaceships would.

I did implement that in my original long ago in AMOS because those were spaceships flying out. The ships only changed to point in 8 directions I had images created for but still looked fine. I would probably do the same kind of thing for this limiting the rotation to 45 degrees.

I guess I could add it but I want to basically just wrap this up and release it tonight. My mind is going on to my ultra low res game now. I'm getting the urge to make an actual game again instead of these little tutorial style projects.
TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 7th Apr 2018 22:58 Edited at: 7th Apr 2018 22:59
Okay, I just did some work to wrap this up for release here on the forum hopefully tonight.

This session I added a bunch of text notes to the top of the main.agc file. Of course a lot of that is the standard hey use this at your own risk don't blame me for your stove not working an hour later, etc etc.

But I did touch up the code a bit here and there and then made a custom html game page for it.



Just looks better. Streamlined removing the background image and reducing the canvas height to match the window proportions and adding a border around the actual game window. Oh and adding the project name above it.

Alright I will work on this again later to hopefully wrap it up completely.

It is actually a lot of fun playing this although there is only 1 minute of gameplay in there.
TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 7th Apr 2018 23:31 Edited at: 7th Apr 2018 23:49
Love what you have done here GarBenjamin very useful and something good for others to learn from

I created a map editor and a path editor and wanted to use these for a game similar to Xevious i found issues with
getting the path movements aligned with the scrolling tiles. But that project is on the backburner at the moment
but https://forum.thegamecreators.com/thread/221603 in particularly the video at the bottom shows
an endless scrolling background with tanks that move on the same path at the moment with links to my tile editor
and path editor. But i never got the diversity you achieved in your paths like you have above.

Great stuff and another good thread
fubar
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 8th Apr 2018 03:25 Edited at: 8th Apr 2018 04:20
I am calling this AGK2 Shmup Template DONE!

Full project source code is attached. 830 KB

LOAD IT INTO AppGameKit2 and RUN IT! It's just a template but I find the 1 minute of gameplay to be fun.

Move with Arrows or WASD
Fire with X, C, Enter or Shift
Esc to quit playing and return to the Title Screen
Esc at Title Screen to quit or just use the Quit option
Controller support is in as well. It scans all 8 possible controllers and uses the first one it finds.

Mobile support is already added so just use the virtual buttons in that case.


Some extra size for the zip just because I left 24 audio files for sound FX I created using BFXR that are not used. Just figured someone might be able to use them.

In the Builds/HTML5 folder you will find a file named "customTemplateForWebGame.html this is the custom web game page which will look like this...


Let's see... hit F1 at the Title Screen to bring up the Motion Designer. Hit Esc in Motion Designer to return to Title Screen.

Basically read the comments at the top of the main.agc file it covers stuff like accessing the Motion Designer and other important information.

Thanks to Phaelax, AMON, fubarpk and everyone else who posted here.

I hope people find this helpful and it would be very cool to see some shmups come out of it.


------------------------------

The next time I do a game dev session it will either be on the Retro 3D FPS or a new project to make a complete game for release. I haven't done that in a while and think I would like to.

This is my last mock-up for resolution and sprite sizes.
TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)

Attachments

Login to view attachments
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 8th Apr 2018 04:02
Great Stuff Garbenjamin thanks for sharing
fubar
kragoth74
6
Years of Service
User Offline
Joined: 3rd May 2017
Location:
Posted: 8th Apr 2018 08:11
Very nice, thank you for sharing.
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 10th Apr 2018 06:21
Glad you like it!
TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)

Login to post a reply

Server time is: 2024-04-19 06:22:09
Your offset time is: 2024-04-19 06:22:09