SyntaxBomb - Indie Coders

General Category => Worklogs => Topic started by: 3DzForMe on May 07, 2020, 22:17:10

Title: Reboot comp: WestisBest
Post by: 3DzForMe on May 07, 2020, 22:17:10
Well, progress has been slow. Figured out how to detect a keypress in AGK.... took me a bit longer than expected. Repeat - google is your friend.....

Was gobsmacked at how many commands there are in AGK..... Need to find if AGK has a scancode thingy like IDEal.... I mean native Blitz3D IDE - my IDEal on this computer doesn't have the help files functional currently.

So, successes:

P1 moves up and down and shoots.

To Dos:

Just about everything else.

Hmmm, chances of this becoming a game - slim.

t-minus 2 days........ :o

[edit]  Initial feedback from my user group (18 year old daughter) says it already looks better than the original as the whole 2d meets 3d didn't work for her. Yay.
Title: Re: Reboot comp: WestisBest
Post by: Steve Elliott on May 07, 2020, 22:39:04
Quote
Initial feedback from my user group (18 year old daughter) says it already looks better than the original as the whole 2d meets 3d didn't work for her. Yay.

So that's encouraging, cool.   8)

Quote
Figured out how to detect a keypress in AGK.... took me a bit longer than expected. Repeat - google is your friend.

Was gobsmacked at how many commands there are in AGK.

Yes Google is definitely your friend with AGK, type AGK and the area of interest into Google and it comes up with a link.  Luckily the documentation is excellent, but yes this competition has taught me a lot about AGK too.  Scancodes?  Just google it as required: https://www.appgamekit.com/documentation/guides/scancodes.htm

Quote
t-minus 2 days........ :o

Don't panic people!!  :o  Steve panicking.



Title: Re: Reboot comp: WestisBest
Post by: 3DzForMe on May 07, 2020, 22:44:44
QuoteYes Google is definitely your friend with AGK, type AGK and the area of interest into Google and it comes up with a link.  Luckily the documentation is excellent, but yes this competition has taught me a lot about AGK too.  Scancodes?  Just google it as required: https://www.appgamekit.com/documentation/guides/scancodes.htm

Thanks for that - bookmarked - was making the initial mistake of trying to glean where getrawkeypress was from example projects.

The second person in my usergroup (the wife) says the 2d one is already better on the eye than my 3D one. Hmmm, might have to insert sincere effort to squeeze more AGK syntax into the old suede.
Title: Re: Reboot comp: WestisBest
Post by: iWasAdam on May 08, 2020, 06:57:04
Hi 3Dz I thought I'de give you something to think over.
Using the image above I overlayed the original boot hill and did some quick markouts of how the screen is used which yoou might find helpful:
(https://vjointeractive.files.wordpress.com/2020/05/x1.png)

the 2 red areas are the limits of where the players can walk
the green shows the general perspective and drawing of the background
I've enlarged your sprites so they better match the scales.

This gives you a general template to work with, general sizes, etc :)
Title: Re: Reboot comp: WestisBest
Post by: 3DzForMe on May 08, 2020, 18:00:31
Thanks for the feedback Adam, its a tuff call - work on the scenery in the periphery.... or make the game mechanics work. Jeez Louise - (In a Lylat Wars style voice).... might not be going for the No.1 slot this time. well at least it'll give the others a chance ;)

So, to dos. more and then some
Title: Re: Reboot comp: WestisBest
Post by: 3DzForMe on May 08, 2020, 18:36:16
Well, my dinners ready  -  excellent progress on the graphical front....

Any chance of a 14 day extension qube - I've kicked into touch a 600 pound Cisco course to get this effort this far.

Kudos to u Qube for this forum pal.

Title: Re: Reboot comp: WestisBest
Post by: Xerra on May 08, 2020, 22:26:16
Pfft, 14 day extension. We've had Two months already. Thinks that's more time than most of the other compo's. Although I think the movie and tv themed one was 10 weeks.
Title: Re: Reboot comp: WestisBest
Post by: 3DzForMe on May 09, 2020, 05:43:13
Fair one, I'm back in Cisco land - & not the emperor's new groove version ;)
Title: Re: Reboot comp: WestisBest
Post by: 3DzForMe on May 09, 2020, 07:38:47
And.... Ready Player1.....

He can now shoot up to 6 bullets AND the reload magazine appears.

To Dos:

Pretty up bullets and magazine, make bullets KILL P2.

Everything else.
Title: Re: Reboot comp: WestisBest
Post by: 3DzForMe on May 09, 2020, 17:12:17
2gun tex has.... two separate guns that both are six shooters.

failed to hash include a file, read and write paths different for my AGK project, so I just shoehorned my first ever include file in AGK Studio back into good old main.

Next...... To invoke Kill Logic..... :o ???

In other news, reset my Cisco password - so I can now access packet tracer. Great.
Title: Re: Reboot comp: WestisBest
Post by: 3DzForMe on May 10, 2020, 06:32:42
Player 1 bullets + physics + score incrementer - done

Player 2 bullets in, no physics or deadliness yet...

Levels and music to put in.

Might be able to improve graphics - and a whole day left to code..... its gonna be tight.  ;D

[EDIT] time_passes# ......  ???
Title: Re: Reboot comp: WestisBest
Post by: MrmediamanX on May 10, 2020, 09:16:56
going right down to the clutch, do it to it man you got this.
Title: Re: Reboot comp: WestisBest
Post by: 3DzForMe on May 10, 2020, 16:14:00
Quotegoing right down to the clutch, do it to it man you got this.


Thanks for the encouragement - I've squeezed in roughly 4 hours of Cisco today and planted 8 rows of vegetables with my daughter.... AI for P2 / the bad guy seems like a HUGE push at the momento.  :-\
Title: Re: Reboot comp: WestisBest
Post by: 3DzForMe on May 10, 2020, 16:55:15
hmmm, anyone familiar with AGK syntax explain why this logic proves to prove true - can you check if a FLOAT is larger than another FLOAT in AGK?

if time_elapsed# >= sevensekcount#

P2shouldashot#=P2shouldashot#+1

sevensekcount# = sevensekcount# - 1

P2fire=1

Endif



Just about to chuck in the old towel......

if time_elapsed# >= sevensekcount#

P2shouldashot#=P2shouldashot#+1.0

sevensekcount# = sevensekcount# - 1.0

P2fire=1

Endif
Title: Re: Reboot comp: WestisBest
Post by: Steve Elliott on May 10, 2020, 17:00:49
For timing I use something like this:


If( ( Timer() - entity[e].anim_timer ) * 1000.0 >= entity[e].anim_speed )

    < update code here >

    entity[e].anim_timer = Timer()

Endif
Title: Re: Reboot comp: WestisBest
Post by: 3DzForMe on May 10, 2020, 17:33:36
thx for the reply - just needed a rest - was able to suss was using the wrong time - what's the time Mr Wolf ?
Title: Re: Reboot comp: WestisBest
Post by: Steve Elliott on May 10, 2020, 18:00:36
lol yes AGK has evolved over time so there are many ways to do things (some legacy code).
Title: Re: Reboot comp: WestisBest
Post by: 3DzForMe on May 10, 2020, 18:01:33
current screen grab P2 shoots......
Title: Re: Reboot comp: WestisBest
Post by: 3DzForMe on May 16, 2020, 08:14:28
@Steve thanks for sharing.

I was using the wrong variable - doh!  Anyhoo, dipped my toe back into WestIsBest's murky coding pond (Well.... it SO not optimized its untrue..... that's what happens when you're hanging stuff together in a new language without getting to grips with the syntax!)

Yep, I defo took the old - just dive into the deep end of AGK's syntax with only one deflated water wing :))

Right, progress report, 3 more minutes coding.... and my P2 bullets killing P1 was working!!!!! Oh, if only I'd known.

I was trying to kill P1 inside a function - but hadn't sussed (still haven't - I'm just decrementing P1 score for now on a computer AI bullet/P1 sprite collision.) how to return a value from a function.

Is it possible to make a 'global' var in AGK that can be manipulated inside a function?

Anyhow, just like the stock market, P1's score can now go up as well as down!!!!  Now, about the gaming submission deadline - oh yeah, missed it.  :o
Title: Re: Reboot comp: WestisBest
Post by: Steve Elliott on May 16, 2020, 09:59:40
To return a value from a function in AGK just put the variable after the Endfunction keyword and global just use the Global keyword before a variable name (outside of any function).



score As Integer = 10
score = AddToScore( score )

Function AddToScore( a_score )

    new_score As Integer = a_score + 10

Endfunction new_score

Title: Re: Reboot comp: WestisBest
Post by: 3DzForMe on May 16, 2020, 10:01:40
Cheers Steve, I can invoke my killplayer1 function now 😁👍
Title: Re: Reboot comp: WestisBest
Post by: Steve Elliott on May 16, 2020, 10:09:08
No problem.  Good luck with your game.   :)
Title: Re: Reboot comp: WestisBest
Post by: 3DzForMe on May 17, 2020, 21:22:30
Chesters Dead - by rights with his lives as low as they are he should be a Zombie ;)
Title: Re: Reboot comp: WestisBest
Post by: 3DzForMe on May 20, 2020, 21:20:49
2guntex is packing some greenades, boom! Well... not yet - need to suss out some trig for some nice arcs.
Title: Re: Reboot comp: WestisBest
Post by: 3DzForMe on May 23, 2020, 12:32:23
Grenades now fly in a parabola... height depending on how much 'force' you put into the throw.... might incorporate Wind as well - not really in keeping with the original, but why not ;) 8)
Title: Re: Reboot comp: WestisBest
Post by: 3DzForMe on May 24, 2020, 06:48:36
Jeez, I thought - I'll just invoke the logic before cracking on with studying (yep....I know) - 40 minutes later I've the logic to vary the height of the parabola for 6 different grenades and a 'get more grenades' box. 
Title: Re: Reboot comp: WestisBest
Post by: iWasAdam on May 24, 2020, 08:13:12
(https://vjointeractive.files.wordpress.com/2020/05/screenshot-2020-05-24-at-08.19.54.png)

local l:float
For l = 0 To Pi Step 0.1
canvas.DrawRect( l*50, Sin(l)*50, 2, 2 )
Next

just swap the 50 for any value, the higher the taller the parabola
Title: Re: Reboot comp: WestisBest
Post by: Derron on May 24, 2020, 09:28:05
do not forget to incorporate a vector for "wind" (offset by windStrength(height)).


Edit: Ok, I assume it is not just "sin(pos) * maxHeight" which 3DzForMe struggles with. He codes something in a 45° half-birds-view. Ok, So just see your axis as triangles.

See the ground as x,y and the height as z. Depending on the viewing angle the amount of "height change" (change of side "z" in a triangle having points x0/z0, x1/z0 and x1/z1) offsets a bullets position on your screens y (so not on the "map's y").


Edit2: to keep it simple: just do it "y = sin(throwProgress) * height * heightModifier". throwProgress defines in percentage (0.0 - 1.0) how far the grenade is thrown from start to "desired x position". Height defines the maximum height of the thrown thing. heightModifier is a linear factor which you adjust until it looks good from the POV in your game (so something about 0.5 might look ok for a 45° view).
The "x movement" could be based on a sin() too ... to simulate that it has to move upwards too.

bye
Ron
Title: Re: Reboot comp: WestisBest
Post by: iWasAdam on May 24, 2020, 10:09:02
That is the most complicated answer I've ever come across derron  :P
Title: Re: Reboot comp: WestisBest
Post by: Derron on May 24, 2020, 11:04:45
It is not complicated - it is just that you can break down most complex stuff into "simple" pieces. So instead of rotation matrices, quaternions etc - you can separate it into points which have most often a triangular relation too each other. And triangles is what most people are able to cope with since school. I mean these 90°-angle triangles with Pythagoras' theorem : a² = b² + c² and Thales' theorem for all triangles. Or stuff like "sin = opposite/hypothenuse".

Especially when "faking" (absolut perfection not required) you can get along with a lot of sin/cos calculations to find positions on the screen.


I think for you (IWasAdam) it is even easier - as all this fake3d-stuff you do relies on this simple mathematics and you surely blindly use them (I have to look up when to use sin, cos or tan)



bye
Ron
Title: Re: Reboot comp: WestisBest
Post by: iWasAdam on May 24, 2020, 11:30:50
QuoteThales' theorem
never heard of it

Quotesin = opposite/hypothenuse
(to quote Ultravox) This means nothing to me... ::)

My math skills are very basic +-/* and sin/cos/atan, plus I know bitwise stuff inside out. I have a mental issue where I can't mentally work in equations or formulae - it all looks gibberish to me. But put me in front of a picture or pure code and I can come up all sorts of wierd stuff...

I've found that sin/cos/atan2/pi seem to form the backbone of almost all computer graphics stuff. Everything else you can fake with a little knowhow.

Even vectors I have to break down into their simple parts and work on them that way. I could tell you what DOT or how matrix works.

gone off topic now.

OK. on topic:

for any line x0,y0,x1,y1
the difference can be found by:
xdiff = float(x1-x0) / 1
ydiff = float(y1-y0) / 1

therefore any position on the line can be found by:
pos = 0..1
xpos = x0 + xdiff * pos
ypos = y0 + ydiff * pos

lets assume we now want to add the sin (and let the Talons of Weng Chiang shred your flesh) <- got carried away again...
height = 30
curve = sin( pi / pos ) * height

just adding this to ypos will give the curve applied to any line:
ypos += curve

Or something very much like it  ;)

Very simple math, no complex 'triangles with bowls law and added bresnal filtering', no formulae, just the simple code \o/
Title: Re: Reboot comp: WestisBest
Post by: Derron on May 24, 2020, 12:01:19
At the end your formula is doing the same which I suggested. I just added a multiplier to decrease the strength of the curve.
Your formula should only be used when doing a side-view.

By lowering the impact of the sin() (sin(x) * max * modifier) you can "fake" viewing it from a different angle. Assume 90° (top view) you end with "y :+ sin(whatever) * maxHeight * 0" (so nothing is added) and with 0° (side view) you use "y :+ sin(whatever) * maxHeight * 1.0".



Nonetheless: in most "standard cases" you just use the formula of the "throw" and use a individual throwing angle which then - together with initial velocity ("strength of throwing") you calculate where it lands.
Of course you could now reverse the formula to have a given landing spot and with a fixed throwing angle calculate the initial speed (and velocity).


@ Thales theorem
Ok, not so important in this particular case here :D. I mixed it up with "Geometric mean theorem" (which is in German "Euklids Höhensatz" - height theorem of Euclid). As this is one of the 3 theorems about right angled triangles - in which you can split many many 3d problems. As you (iWasAdam) wrote: a bit of sin, tan ... and there you go.


bye
Ron

Title: Re: Reboot comp: WestisBest
Post by: 3DzForMe on May 24, 2020, 21:52:59
@Derron & iWasAdam...

Yep, my initial thoughts were - right, I need to use trig to do this parabola magic.

turns out you don't with AGK.

Here we go.... Video attached - AGK has built in physics.

Note to self though - I'm shit at coding.

Spent about an hour trying to fathom why the hell the physics wasn't working....

Turns out the physics isn't a VECTOR thing in AGk (i.e. apply physics and watch it go......)

You need to keep applying the force every iteration of the do / while loop. DOH!

Oh well, I'm done for tonight.  Spent AGES trying to fathom if it was somewhere in my fog of an array
of grenadas causing the problem. Nope - just a lack of understanding I needed to prod the sprite
with the 'force' every iteration of the loop.

Yep, Wind is an idea - but for now, I'm just glad to have a parabolic grenade!!!!!
Title: Re: Reboot comp: WestisBest
Post by: Steve Elliott on May 24, 2020, 22:56:47
AGK is really good, runs on all systems, but I tend to stay away from some of the extra built-in features whenever possible and write my own code - I just use the core.
Title: Re: Reboot comp: WestisBest
Post by: 3DzForMe on May 31, 2020, 14:30:59
Cheers Steve, 2-gun Tex now has 3 out a 6 of his grenades flying.... Might make them proximity grenades, nah, that could be the claymores for level 4 ;D
Title: Re: Reboot comp: WestisBest
Post by: 3DzForMe on May 31, 2020, 14:33:18
Oh.... By the way this title really needs changing to Reboot {missed}, don't want to end up winning with a non-entre.  ???
Title: Re: Reboot comp: WestisBest
Post by: 3DzForMe on June 04, 2020, 20:32:55
Grenades collision detection now works on the AI P2 dood, doesn't make him deed yet though!
Title: Re: Reboot comp: WestisBest
Post by: 3DzForMe on July 10, 2020, 17:27:20
Bang appears....Note to self - Sprite hierarchy can result in Sprites being 'hidden' behind other sprites.....
Title: Re: Reboot comp: WestisBest
Post by: 3DzForMe on July 10, 2020, 17:34:19
Note to self:  Sprite Z-order:

https://www.appgamekit.com/documentation/examples/sprites/14_sprite_depth.htm
Title: Re: Reboot comp: WestisBest
Post by: 3DzForMe on July 25, 2020, 06:48:18
Ah so much progress this morning, P1's first gun's bullets (Well he is 2 gun-tex after all...) now... wait for it..... actual come out of the nozzle of the gun.

And, P1's grenade, when it goes bang, has an advers affect on P2's life force.  I know, at this rate it'll be ready for Christmas release... then I'll have to change the sand snowy.... Yes, two gun Tex may have to survive the seasons, like Forza Horizons 2 (if  I got the number right, theres so many damn releases of that now).

Gimme Project Cars 2 with its B******D hard F1 races.
Title: Re: Reboot comp: WestisBest
Post by: 3DzForMe on July 25, 2020, 21:13:09
OMG, OMG, my reload function is working.  Now.... just need to get the supply wagon to drop off re-supply crates at appropriate times per level.

The last competition hasn't finished yet has it  :o

My little joke.  Loving a bit of coding fun ..... ;)

I'm inclined to go for a 'life bar' as opposed to 'lives'.  The SLR went out of service because it was too good at reducing life force.  Inclined to work different revolvers into 2 gun tex's arsenal.
Title: Re: Reboot comp: WestisBest
Post by: Qube on July 26, 2020, 02:03:16
Congratulations :) Good to hear you kept tapping away until it was working 8) - As the Borg would say.. "Persistence is not futile" or was it "resistance is futile"? huh, can never remember these days.

QuoteThe last competition hasn't finished yet has it  :o
No no, you keep coding on there, plenty of time yet ;D
Title: Re: Reboot comp: WestisBest
Post by: 3DzForMe on August 29, 2020, 09:58:42
Quote.    :) Good to hear you kept tapping away until it was working 8) - As the Borg would say.. "Persistence is not futile" or was it "resistance is futile"?   

I think it was the latter. First guns bullets stop, rather than going straight thru P2, WestIsBest creeps ever forwards.  :D