May 31, 2020, 09:44:29 PM

Author Topic: Reboot comp: WestisBest  (Read 692 times)

Offline 3DzForMe

  • Hero Member
  • *****
  • Posts: 1023
Re: Reboot comp: WestisBest
« Reply #15 on: May 10, 2020, 05:33:36 PM »
thx for the reply - just needed a rest - was able to suss was using the wrong time - what's the time Mr Wolf ?

Online Steve Elliott

  • Hero Member
  • *****
  • Posts: 2454
Re: Reboot comp: WestisBest
« Reply #16 on: May 10, 2020, 06:00:36 PM »
lol yes AGK has evolved over time so there are many ways to do things (some legacy code).
Windows 10, 64-bit, 16Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb).
MacOS Catalina, 64-bit, 8Gb RAM, CPU Intel i5, 2.3 Ghz, Intel Iris Plus Graphics 640 1536 MB.
Linux Mint 19.3, 64-bit, 16Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb).
Raspberry pi 3 and 4.

Offline 3DzForMe

  • Hero Member
  • *****
  • Posts: 1023
Re: Reboot comp: WestisBest
« Reply #17 on: May 10, 2020, 06:01:33 PM »
current screen grab P2 shoots......

Offline 3DzForMe

  • Hero Member
  • *****
  • Posts: 1023
Re: Reboot comp: WestisBest
« Reply #18 on: May 16, 2020, 08:14:28 AM »
@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

Online Steve Elliott

  • Hero Member
  • *****
  • Posts: 2454
Re: Reboot comp: WestisBest
« Reply #19 on: May 16, 2020, 09:59:40 AM »
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).

Code: [Select]

score As Integer = 10
score = AddToScore( score )

Function AddToScore( a_score )

    new_score As Integer = a_score + 10

Endfunction new_score

Windows 10, 64-bit, 16Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb).
MacOS Catalina, 64-bit, 8Gb RAM, CPU Intel i5, 2.3 Ghz, Intel Iris Plus Graphics 640 1536 MB.
Linux Mint 19.3, 64-bit, 16Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb).
Raspberry pi 3 and 4.

Offline 3DzForMe

  • Hero Member
  • *****
  • Posts: 1023
Re: Reboot comp: WestisBest
« Reply #20 on: May 16, 2020, 10:01:40 AM »
Cheers Steve, I can invoke my killplayer1 function now 😁👍

Online Steve Elliott

  • Hero Member
  • *****
  • Posts: 2454
Re: Reboot comp: WestisBest
« Reply #21 on: May 16, 2020, 10:09:08 AM »
No problem.  Good luck with your game.   :)
Windows 10, 64-bit, 16Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb).
MacOS Catalina, 64-bit, 8Gb RAM, CPU Intel i5, 2.3 Ghz, Intel Iris Plus Graphics 640 1536 MB.
Linux Mint 19.3, 64-bit, 16Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb).
Raspberry pi 3 and 4.

Offline 3DzForMe

  • Hero Member
  • *****
  • Posts: 1023
Re: Reboot comp: WestisBest
« Reply #22 on: May 17, 2020, 09:22:30 PM »
Chesters Dead - by rights with his lives as low as they are he should be a Zombie ;)

Offline 3DzForMe

  • Hero Member
  • *****
  • Posts: 1023
Re: Reboot comp: WestisBest
« Reply #23 on: May 20, 2020, 09:20:49 PM »
2guntex is packing some greenades, boom! Well... not yet - need to suss out some trig for some nice arcs.

Offline 3DzForMe

  • Hero Member
  • *****
  • Posts: 1023
Re: Reboot comp: WestisBest
« Reply #24 on: May 23, 2020, 12:32:23 PM »
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)

Offline 3DzForMe

  • Hero Member
  • *****
  • Posts: 1023
Re: Reboot comp: WestisBest
« Reply #25 on: May 24, 2020, 06:48:36 AM »
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. 

Offline iWasAdam

  • Hero Member
  • *****
  • Posts: 1718
Re: Reboot comp: WestisBest
« Reply #26 on: May 24, 2020, 08:13:12 AM »

Code: [Select]
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

Offline Derron

  • Hero Member
  • *****
  • Posts: 2975
Re: Reboot comp: WestisBest
« Reply #27 on: May 24, 2020, 09:28:05 AM »
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

Offline iWasAdam

  • Hero Member
  • *****
  • Posts: 1718
Re: Reboot comp: WestisBest
« Reply #28 on: May 24, 2020, 10:09:02 AM »
That is the most complicated answer I’ve ever come across derron  :P

Offline Derron

  • Hero Member
  • *****
  • Posts: 2975
Re: Reboot comp: WestisBest
« Reply #29 on: May 24, 2020, 11:04:45 AM »
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

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal