November 27, 2020, 05:51:42 AM

Author Topic: Maze Raider - The aMAZEing code a game comp entry  (Read 13097 times)

Offline Derron

  • Hero Member
  • *****
  • Posts: 3262
Re: [ WIP ] Competition entry: Maze Raider
« Reply #45 on: October 06, 2018, 12:16:46 PM »
Still fiddling with the button not emitting signals ... but layed that aside and tried to come up with some "GUI" and "HUD" stuff.

Trying for half an hour now to use a sprite atlas as source for a ninepatch rectangle. I mean... for me it is obvious to have HUD/GUI sprites designed on a single image. So best thing is to just set up the coordinates/dimensions for such a sprite in the editor and then use this sprite for whatever I want it. Right? But seems Godot is (again) not capable of doing a specific thing. You can save the sprite you configured "on" your sprite atlas. But once you want to use this sprite as source for a ninepatch rect - it uses the whole image again. Seems as if "coordinates" are absolute and not "sprite relative" (which would allow usage out of a spritesheet/atlas). As the ninepatch thing configures as "left col width, right col width, top row height, bottom row height" you even cannot trick around (eg. one could define top left x,y,w,h, top x,y,w,h, top right x,y,w,h ... and voila, no trouble).

Means at the end I need to cut my spritesheed by hand/tool just to make it work "somehow" in Godot. Editing a bit within the GUI? Cut it again afterwards ... WOW, such a timesaver, not!

I see limitations all around the corners and it feels more and more as if I used a Flash-game designer-toolkit.
Nonetheless I am aware that there are surely some other options to achieve what I want in Godot - but hell, it is hard to find solutions within minutes - I do not want to search the internet everytime I want to use a feature I just _expect_ from a toolkit like Godot. Regarding 9patch: in my DIG-Framework it is not a big portion of code enabling what I described above and source of my ninepatches can be single images or spritesheets - did not try animations yet but it is the same: another sprite on the sheet which gets cut into 9 pieces.



Edit: Aeeehm... whatever. Did not change anything but now - it works as expected. At least a "NinePatchRect" can now use a portion of a SpriteAtlas. TextureButton still does not handle the 9 patch button (means: no scaling). Maybe it has some caching issues, I just checked and unchecked a box and resized the button - and the ninepatch "snapped" in - instead of using the whole texture it now properly uses the small sprite. I do not know what to say - such "bugs" are annoying as you now never know: is this a bug in the editor, or is this feature in the engine bugged? grrr.
And as it is surely not reproduceable I even cannot file an issue.
So for now I would need to code my own "Button" behaviour on top of a ninepatch sprite.
I think it is not worth the hassle, as this also means for "nine-patch stuff" I need to code my own "progress bar", "input" ... and the likes.


Fighting a "bug": 30 minutes
Crying about it in the syntaxbomb forums: 10 minutes
Lost time of my lunch break: 40 minutes in total

Mphhhf!

bye
Ron

Offline Matty

  • Hero Member
  • *****
  • Posts: 1253
    • MattiesGames
Re: [ WIP ] Competition entry: Maze Raider
« Reply #46 on: October 06, 2018, 12:20:35 PM »
So...would you use this godot thing by choice for a project that was your own free choice normally? Or is this just a learning experience?

Offline Derron

  • Hero Member
  • *****
  • Posts: 3262
Re: [ WIP ] Competition entry: Maze Raider
« Reply #47 on: October 06, 2018, 12:29:57 PM »
I want to use it (or Unity) to try out more things than just BlitzMax for "game/tools", Java for "applications at work" (some android stuff) or php/mysql/jscript when it comes to websites.

There must be a reason so many use Unity for games - and especially for "3D" there seems to be no convenient solution for BlitzMax - if you are, like me, an absolute beginner when it comes to 3D games programming (while I have ~20 years of "amateur experience" in 3D software).
Godot is open source - which I favor - so I thought I will try it first (instead of Unity). Thought that it will surely provide what my "simple games" will need.

So - yes - for this competition I wanted to try out something new, Godot. I always aim to learn something new with these competitions (eg. in Blender: better texture painting, workflows for 3D assets from 3d tool to 3d engine). I am pretty sure that other "similar" games (tile/gridmap based things) will be easier to code in Godot for me from now on and so it is a potential software for other little games. As said I am surely most often fighting myself instead of (the software) Godot.


 
bye
Ron

Offline Derron

  • Hero Member
  • *****
  • Posts: 3262
Re: [ WIP ] Competition entry: Maze Raider
« Reply #48 on: October 06, 2018, 01:06:00 PM »
OK, fixed that "buttons do not react to clicks": my screen transition element(which is on a layer on top of the game) contained a "TextureRect" which overlayed everything. This "TextureRect" is not a simple "texture rectangle" but here in Godot it is extending "control". Controls are there for GUI/HUD stuff - which means it seems to listen to mouse/input interaction. I needed to set mouse interaction to "ignore" and voila... it goes "through".


Editor screenshots:




(as you see - with ninepatch I need to handle my own "normal/hovered/pressed"-visual representation stuff)


Lol: seems syntaxbomb and Godot use the same gray tone... :-)


Ok, family will arrive soon, so coding for today seems to be done. At least a "issue" solved.


bye
Ron

Offline Qube

  • Administrator
  • Hero Member
  • *****
  • Posts: 2565
  • I mostly code at night... Mostly.
    • SyntaxBomb - Indie Coders
Re: [ WIP ] Competition entry: Maze Raider
« Reply #49 on: October 06, 2018, 06:26:25 PM »
Quote
Lol: seems syntaxbomb and Godot use the same gray tone... :-)
Huh! that's pretty weird :P
Mac mini ( 2018 / 2020 ), 3 GHz 6-Core Intel Core i5, 16 GB 2667 MHz DDR4, 1TB NVMe, eGPU Radeon Pro 580 8 GB, LG Ultragear 27GL83A-B 27 Inch
Commodore VIC-20, 1.1Mhz MOS 6502 CPU, 5KB RAM, VIC ( 6560 ) GPU

Until the next time...

Offline Steve Elliott

  • Hero Member
  • *****
  • Posts: 2858
  • elgol 2021
Re: [ WIP ] Competition entry: Maze Raider
« Reply #50 on: October 06, 2018, 06:59:22 PM »
What person in their right mind designs a coding theme with a bright white background and black text?!  #eyestrain.  Dark Theme all the way for me!
Windows 10 64-bit, 16Gb RAM, Intel i5 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb)
MacOS Big Sur 64-bit, 8Gb RAM, Intel i5 2.3 Ghz, Intel Iris Plus Graphics 640 1536 MB
Linux Mint 19.3 64-bit, 16Gb RAM, Intel i5 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb)
Raspberry Pi 400, Pi4, C64, ZX Spectrum Next.

Offline Derron

  • Hero Member
  • *****
  • Posts: 3262
Re: [ WIP ] Competition entry: Maze Raider
« Reply #51 on: October 07, 2018, 08:16:21 AM »
Odd behaviour of today?
I added some "spawn creature triggers" (will get replaced with sarkophags or so). They spawn creatures at the given grid.

To do this you have to:
- create an instance of the creature object (in Godot: "scene")
- move it to the desired position (set/adjust translation of the instance)
- add it to the node tree (so it gets rendered)


This is exactly what I do - so translation is done right before it gets added to the node, aka it is moved before it can get rendered. But still added ones are first rendered at "0,0,0"  and are then moved/"snapped" to their target position.
I also "debug printed" some stuff - and it claimed to have set translation as I wanted it to do.


Code: [Select]
func AddUnit(unitID, col=-1, row=-1):
var unit = preload("res://Scenes/Creature.tscn").instance()
print("AddUnit: ", unit.get_name(),"  translation=", unit.translation)
if col == -1 or row == -1:
var tile = GetRandomWalkableMapTile()
if tile:
col = tile.col
row = tile.row
else:
print("no tile found")
if col == -1 or row == -1:
print("no free slot found")
if col == -1: col = 1 + randi() % (mapCols-2)
if row == -1: row = 1 + randi() % (mapRows-2)

unit.set_translation(Vector3(col * TILEMAP.TILE_SIZE, 0, row * TILEMAP.TILE_SIZE))
unit.RefreshGridPosition()

AddMapTileObject(col, row, GLOBAL.GROUP_HOSTILE_CREATURES, unit)
print("         -> grid=", unit.gridCol,",",unit.gridRow, "  translation=", unit.translation)
emit_signal("unit_add", unit, col ,row)
return unit

output was:
Code: [Select]
AddUnit: Creature  translation=(0, 0, 0)
         -> grid=6,2  translation=(12, 0, 4)

So as you see it correctly changed object's translation ... I even removed potentially interferences and really cut it down to:
- create instance, set translation, add to node tree
and it still ... has this annoying visual "jump". I must have missed something. grr.


bye
Ron

Offline Matty

  • Hero Member
  • *****
  • Posts: 1253
    • MattiesGames
Re: [ WIP ] Competition entry: Maze Raider
« Reply #52 on: October 07, 2018, 08:27:26 AM »
What if you set it to invisible for one frame first?

Offline Derron

  • Hero Member
  • *****
  • Posts: 3262
Re: [ WIP ] Competition entry: Maze Raider
« Reply #53 on: October 07, 2018, 08:43:29 AM »
Yes, invisibility or having some kind of "getting added"-animation (scale up, fade in , ... whatever fits) was on my "circumvention list" already.

But I want to understand why it happens at all. It is not a threaded build - so I assume "adding + placement" is done straight each after another. I am pretty sure that I have done something somewhere (checkboxes, or similar) which I shouldn't.
I cannot see this happening for some other items (the collectible "yellow boxes" for now).

Will try to fix it at lunch.


bye
Ron

Offline Derron

  • Hero Member
  • *****
  • Posts: 3262
Re: [ WIP ] Competition entry: Maze Raider
« Reply #54 on: October 07, 2018, 11:55:55 AM »
While on initialization of such a spawned item an:
visible = false
yield("0.05 second"-timer, "timeout")
visible = oldVisible

"covers" the initial bug I tried a lot of stuff. It's not an attached script issue (replaced the script of the creatures with that of the collectibles). Thought maybe physics are the culprit (I have a particly system attached to the creatures but not the collectibles). Seems not to be the issue too.
Argh...
Ok, so leaving on the "invisible"-fix for now.


Meanwhile I got another issue: when the player dies it actually does a "StartDying()" and a "FinishDying()" (so I could play animations properly - or just extend whatever happens in that moments in extending types/classes).
When tween for "dying" (swirl, scale to "up to zero") ends, a signal is emitted automatically (inbuilt signal) - "tween_completed". For exactly one time a single listener to listen to this signal is registered (I print out a "connected to signal" right below the connection-establishing - and this line is only printed once). I also gave the "to call" method/callback a unique name so that other scripts might not interfer. When I start the tweening process I also print out a debug message - which is also only printed once.
Ok ... so guess what happens? This signal listener is called twice in a row. How can this be ... ? For now I could fix that by only reacting if a certain flag is set.

I feel a bit lost by fighting all these little annoyancies.


bye
Ron

Offline Derron

  • Hero Member
  • *****
  • Posts: 3262
Re: [ WIP ] Competition entry: Maze Raider
« Reply #55 on: October 07, 2018, 12:40:45 PM »
Grr.. ok, that signal issue is ... I would call it not a bug but a missing feature.. in a "Tween" node you can chain up multiple individual tweens (eg. one for location, another for scale and a third for rotation).

Tween (as of now) emits a "tween_completed" signal for _each_ of these individual tweens - but none for "finished with everything".

This is the reason why I received the signal multiple times. Means I need to take care for myself how many "individual tweens" are stored within one big "Tween node" (and subtract then for each finished - only reacting then if the last one finishs). Annoyance!


Edit: seems in v3.1 this _will_ be fixed in a way that "tween.is_active()" returns false once all tweens finished. A pity that I am at the latest release: v3.0.6.

bye
Ron

Offline Qube

  • Administrator
  • Hero Member
  • *****
  • Posts: 2565
  • I mostly code at night... Mostly.
    • SyntaxBomb - Indie Coders
Re: [ WIP ] Competition entry: Maze Raider
« Reply #56 on: October 07, 2018, 01:49:26 PM »
Sounds like Godot is as much a WIP as your game :o - Keep plodding on though and finish :)
Mac mini ( 2018 / 2020 ), 3 GHz 6-Core Intel Core i5, 16 GB 2667 MHz DDR4, 1TB NVMe, eGPU Radeon Pro 580 8 GB, LG Ultragear 27GL83A-B 27 Inch
Commodore VIC-20, 1.1Mhz MOS 6502 CPU, 5KB RAM, VIC ( 6560 ) GPU

Until the next time...

Offline Derron

  • Hero Member
  • *****
  • Posts: 3262
Re: [ WIP ] Competition entry: Maze Raider
« Reply #57 on: October 07, 2018, 01:58:33 PM »
Yes I will try. So this weekend was/will be short (next family party - big families need multiple parties to get all under one roof ;-)) but at least I got some basic:
- start menu (needs some more love put into design ...)
- player can die (burn baby burn!)
- game over notification
- score notification
- basic HUD elements/icons

plenty to tryout/do:
- open final door/reveal final treasure to fetch/ ... once you collected all requested elements
- add music
- add sfx
- create player / enemies / collectibles + animations for walking/raise from the grave/ ...
- create difficulties (more enemies, more traps ...)
- decorations for the level (make it look "nicer")

pheww. At least some of this stuff is done in Blender so should create _less_ trouble ;-)


bye
Ron

Offline Qube

  • Administrator
  • Hero Member
  • *****
  • Posts: 2565
  • I mostly code at night... Mostly.
    • SyntaxBomb - Indie Coders
Re: [ WIP ] Competition entry: Maze Raider
« Reply #58 on: October 08, 2018, 06:30:46 AM »
OMG! looks like you've an arse load still to do :o - Better ring the family and tell them to stop visiting so you can finish it off ;D
Mac mini ( 2018 / 2020 ), 3 GHz 6-Core Intel Core i5, 16 GB 2667 MHz DDR4, 1TB NVMe, eGPU Radeon Pro 580 8 GB, LG Ultragear 27GL83A-B 27 Inch
Commodore VIC-20, 1.1Mhz MOS 6502 CPU, 5KB RAM, VIC ( 6560 ) GPU

Until the next time...

Offline Derron

  • Hero Member
  • *****
  • Posts: 3262
Re: [ WIP ] Competition entry: Maze Raider
« Reply #59 on: October 08, 2018, 01:26:30 PM »
Lunch time used to create some simple tiles:
- door with border and stairs
- some ground tiles to potentially cover objects going below "ground" (eg. stairs or moving-down-doors at the bottom of the level)
- sarkophag (including simple "open" animation)
- painted backsides of the walls :-)




Let's see if this evening offers me some spare time or not. Wifey time can be everyday so ... surprise surprise.

bye
Ron

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal