Reboot comp: WestisBest

Started by 3DzForMe, May 07, 2020, 22:17:10

Previous topic - Next topic

3DzForMe

thx for the reply - just needed a rest - was able to suss was using the wrong time - what's the time Mr Wolf ?
BLitz3D, IDEal, AGK Studio, BMax, Java Code, Cerberus
Recent Hardware: Dell Laptop
Oldest Hardware: Commodore Amiga 1200 with 1084S Monitor & Blitz Basic 2.1

Steve Elliott

lol yes AGK has evolved over time so there are many ways to do things (some legacy code).
Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb

3DzForMe

current screen grab P2 shoots......
BLitz3D, IDEal, AGK Studio, BMax, Java Code, Cerberus
Recent Hardware: Dell Laptop
Oldest Hardware: Commodore Amiga 1200 with 1084S Monitor & Blitz Basic 2.1

3DzForMe

@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
BLitz3D, IDEal, AGK Studio, BMax, Java Code, Cerberus
Recent Hardware: Dell Laptop
Oldest Hardware: Commodore Amiga 1200 with 1084S Monitor & Blitz Basic 2.1

Steve Elliott

#19
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

Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb

3DzForMe

Cheers Steve, I can invoke my killplayer1 function now 😁👍
BLitz3D, IDEal, AGK Studio, BMax, Java Code, Cerberus
Recent Hardware: Dell Laptop
Oldest Hardware: Commodore Amiga 1200 with 1084S Monitor & Blitz Basic 2.1

Steve Elliott

No problem.  Good luck with your game.   :)
Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb

3DzForMe

Chesters Dead - by rights with his lives as low as they are he should be a Zombie ;)
BLitz3D, IDEal, AGK Studio, BMax, Java Code, Cerberus
Recent Hardware: Dell Laptop
Oldest Hardware: Commodore Amiga 1200 with 1084S Monitor & Blitz Basic 2.1

3DzForMe

2guntex is packing some greenades, boom! Well... not yet - need to suss out some trig for some nice arcs.
BLitz3D, IDEal, AGK Studio, BMax, Java Code, Cerberus
Recent Hardware: Dell Laptop
Oldest Hardware: Commodore Amiga 1200 with 1084S Monitor & Blitz Basic 2.1

3DzForMe

#24
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)
BLitz3D, IDEal, AGK Studio, BMax, Java Code, Cerberus
Recent Hardware: Dell Laptop
Oldest Hardware: Commodore Amiga 1200 with 1084S Monitor & Blitz Basic 2.1

3DzForMe

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. 
BLitz3D, IDEal, AGK Studio, BMax, Java Code, Cerberus
Recent Hardware: Dell Laptop
Oldest Hardware: Commodore Amiga 1200 with 1084S Monitor & Blitz Basic 2.1

iWasAdam

#26


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

Derron

#27
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

iWasAdam

That is the most complicated answer I've ever come across derron  :P

Derron

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