Ooops
September 23, 2021, 06:27:17

Author Topic: Wuhan Gang - Virus Competition Entry  (Read 4069 times)

Offline Steve Elliott

  • Hero Member
  • *****
  • Posts: 3229
  • elgol
Re: Wuhan Gang - Virus Competition Entry
« Reply #15 on: March 06, 2021, 16:42:17 »
I much prefer modern jump dynamics where you have a short window to change direction or double jump.  Rather than old classics like Manic Miner where you got your jump wrong and can only sit and watch as the jump animation runs it's course so you hit something you wanted to avoid.
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 3, pi 4, pi 400, BBC B, C64, ZX Spectrum

Offline STEVIE G

  • Hero Member
  • *****
  • Posts: 608
Re: Wuhan Gang - Virus Competition Entry
« Reply #16 on: March 06, 2021, 17:50:26 »
So just checked what int() was giving me for fractions incrementing at .5.  FFS!!  Why round up at 51.5 and down at 52.5, wheres the consistency? Is this normal?

Anywho, that explains the jerky animation. Floor seems to do the job int can't!

50.5 = 50
51.0 = 51
51.5 = 52 !
52.0 = 52
52.5 = 52 !
53.0 = 53
53.5 = 54

Cheers Steve, I'm looking to have air control around half ground acceleration, so retain launch velocity but can be modified sightly.

Offline Steve Elliott

  • Hero Member
  • *****
  • Posts: 3229
  • elgol
Re: Wuhan Gang - Virus Competition Entry
« Reply #17 on: March 06, 2021, 18:24:00 »
Quote
Why round up at 51.5 and down at 52.5, wheres the consistency? Is this normal?...Floor seems to do the job int can't!

That's ridiculous, IMO .5 and up and you should *always* round up.  So you're rounding down with floor then, at least it's now consistant.  You should have a command/toggle for rounding up or down.

Quote
Cheers Steve, I'm looking to have air control around half ground acceleration, so retain launch velocity but can be modified sightly.

Cool.  Yes, reward the skillful player with the option to adjust mid-flight.


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 3, pi 4, pi 400, BBC B, C64, ZX Spectrum

Offline Derron

  • Hero Member
  • *****
  • Posts: 3651
Re: Wuhan Gang - Virus Competition Entry
« Reply #18 on: March 06, 2021, 19:07:59 »
So just checked what int() was giving me for fractions incrementing at .5.  FFS!!  Why round up at 51.5 and down at 52.5, wheres the consistency? Is this normal?

Anywho, that explains the jerky animation. Floor seems to do the job int can't!

50.5 = 50
51.0 = 51
51.5 = 52 !
52.0 = 52
52.5 = 52 !
53.0 = 53
53.5 = 54

This is because "50.5" is not stored as "50.5" but as something which computer 1 prints as "50.5000003" and the other one as "50.4999997".

So when you do "mynumber :+ 0.5" it might result in "50.4999997 + 0.5" = "50.9999997". Then casting it to int just removes the fraction stuff -> 50.


Nonetheless it does not explain how "int(51.5)" can result in 52.

bye
Ron

Offline STEVIE G

  • Hero Member
  • *****
  • Posts: 608
Re: Wuhan Gang - Virus Competition Entry
« Reply #19 on: March 06, 2021, 19:11:32 »
Thought good old 'Ron would explain this one, thank you. Float precision is gash!

Offline blinkok

  • Sr. Member
  • ****
  • Posts: 375
Re: Wuhan Gang - Virus Competition Entry
« Reply #20 on: March 06, 2021, 21:06:17 »
floor(number+0.5)
That is if floor works

Offline Derron

  • Hero Member
  • *****
  • Posts: 3651
Re: Wuhan Gang - Virus Competition Entry
« Reply #21 on: March 06, 2021, 23:49:22 »
floor(number+0.5)
That is if floor works

if you do the "+0.5" you should be able to just int(thisnumberthen) instead of running through floor()

4.99+0.5 = 5.49 ... int(5.49) = 5
4.51+0.5 = 5.01 ... int(4.51) = 4
4.01+0.5 = 4.51 ... int(4.51) = 4

but if you somehow store 4.5 (so 4.499997 or 4.500003) stuff can fail (4.99997 = 4, 5.00003 = 5)


Had this issue (again) some few weeks ago - all my computers "rounded down" (mine were always x.99999997) but a single computer of a user had an issue ((x+1).000003) ... exactly such a one. Invested some days to move from "double/float" to "long/int" for time stuff. Was hard to narrow down  -as even other users were not able to replicate the issue. The issue was, that for this particular user the game started on "day 2" not "day 1" and he never reported it before :)



bye
Ron
« Last Edit: March 06, 2021, 23:56:14 by Derron »

Offline blinkok

  • Sr. Member
  • ****
  • Posts: 375
Re: Wuhan Gang - Virus Competition Entry
« Reply #22 on: March 07, 2021, 01:19:16 »
Quote
if you do the "+0.5" you should be able to just int(thisnumberthen) instead of running through floor()
In that case, wouldn't int() have exactly the same functionality as floor()?

Offline iWasAdam

  • Hero Member
  • *****
  • Posts: 2453
Re: Wuhan Gang - Virus Competition Entry
« Reply #23 on: March 07, 2021, 07:38:13 »
Stevie, I completely agree with you and have had exactly the same issues with floats not being precise. Here's how I eventually decided to deal with it:

first decide on your precision: 10 positions per unit or 100 positions. You could have 8 or 23 too.

int precision = 10
int positionX = 0
float fX

now you can use positionX with ints, add subtract with ints, the result will always be what you thought it would be, collision etc

when  you need the float version just:
fX = float(positionX) / precision

fX will always be an approximate value




Offline Derron

  • Hero Member
  • *****
  • Posts: 3651
Re: Wuhan Gang - Virus Competition Entry
« Reply #24 on: March 07, 2021, 08:43:00 »
Quote
if you do the "+0.5" you should be able to just int(thisnumberthen) instead of running through floor()
In that case, wouldn't int() have exactly the same functionality as floor()?

what do you think is faster?

Another thing to note (which is important!)
int() -> truncates towards 0
floor() -> truncates towards -inf

example:
int(3.5) = 3
floor(3.5) = 3

int(-1.5) = -1
floor(-1.5) = -2


Also noteworthy: Floor() returns :double
So you cast to integer at the end too.
If your numbers are positive, I would prefer "int" as it should be (did not test that) faster.


I use the int(x+0.5) trick for "mathematical" rounding ">x.5 and <(x+1).5" results in "(x+1)".



Regarding Adams trick/hint:
There were types/classes handling stuff like this. "BigNumbers" or similar stuff. In blitzmax ng you could use "overloading" to overload operators (so "precisionNumber + precisionNumber" would not need the extra division)

The issue you get with Adam's approach is when it comes to root, potencing ...
10^2 = 100
100^2 = 10000

You need to handle the precision potencing too. Think same to say for sinus, cosinus ... and all this stuff. So you might end up with a Struct (speaking about NG) which handles all the math stuff in methods. and then overload the operators to "ease the pain".


But if you only use it with addition/subtraction etc - then KISS like Adam suggested.

Ahh before I forget: using the precision-trick means you limit the integer range! Each precision "step" takes away one digit on the "left side". So maybe at the end you need to use "long" so your numbers still "fit".

bye
Ron

Offline STEVIE G

  • Hero Member
  • *****
  • Posts: 608
Re: Wuhan Gang - Virus Competition Entry
« Reply #25 on: March 07, 2021, 09:12:21 »
Stevie, I completely agree with you and have had exactly the same issues with floats not being precise. Here's how I eventually decided to deal with it:

first decide on your precision: 10 positions per unit or 100 positions. You could have 8 or 23 too.

int precision = 10
int positionX = 0
float fX

now you can use positionX with ints, add subtract with ints, the result will always be what you thought it would be, collision etc

when  you need the float version just:
fX = float(positionX) / precision

fX will always be an approximate value

Yeah, was thinking this might be the best way to go. Cheers.   I'll persevere for a bit as close to nailing it.

Offline STEVIE G

  • Hero Member
  • *****
  • Posts: 608
Re: Wuhan Gang - Virus Competition Entry
« Reply #26 on: March 07, 2021, 17:23:12 »
Today I made the decision to have no traditional menus. What you say, how does that work? Well ....

The entire menu, level select, character select and options are they're own level (the team HQ) so you do everything with your character.

Go down to the options terminals to change stuff and see the results on the teams lounge tv.
If you have the keycard (unlockable after level 1) you can go into the team changing room next to the pool to swap your character.
Start any stage (unlocked as you progress) at any time or redo z previous one for more stars. I left space for more.
The red door is where the boss is going to be.

Really pleased with how this works. Screenshot below.

http://www.steviegoodwin.plus.com/images/Untitled/WG16.png
« Last Edit: March 07, 2021, 17:26:34 by STEVIE G »

Offline Derron

  • Hero Member
  • *****
  • Posts: 3651
Re: Wuhan Gang - Virus Competition Entry
« Reply #27 on: March 07, 2021, 22:57:10 »
The options look all the same to me :-)


Yeah - sometimes these "playable settings" are nice - yet it might be good to have shortcuts to beam the player to the areas ... "o...ptions". Depends on how many things you are placing in there. Aside of that: good idea.


bye
Ron

Offline STEVIE G

  • Hero Member
  • *****
  • Posts: 608
Re: Wuhan Gang - Virus Competition Entry
« Reply #28 on: March 08, 2021, 00:10:48 »
The options look all the same to me :-)


Yeah - sometimes these "playable settings" are nice - yet it might be good to have shortcuts to beam the player to the areas ... "o...ptions". Depends on how many things you are placing in there. Aside of that: good idea.


bye
Ron

The option you're standing beside shows on the monitor, it then changes if you interact with it. You'll probably only need to use options once. Stuff like sound and screen res. If I get time ill have different  consoles graphics. I might also add key bindings in a similar way.

Offline STEVIE G

  • Hero Member
  • *****
  • Posts: 608
Re: Wuhan Gang - Virus Competition Entry
« Reply #29 on: March 09, 2021, 13:06:51 »
Menu / HQ now finished and can now get on with the rest of the game.  ;D

Updated icons for options which are gfx res, gfx mode, 3 x sound volumes and no of players. Had fun with the later as when you change to 2 players another appears on the shelf upper right. If you then change to 1 player he explodes. Rince and repeat for a blood fest.  :))

Joy pad support is also in, you need 2 for coop. Have not added key / button config into menu (maybe if time allows) but you can at least edit these in the options file.

HQ now has a proper boss office with red leather furnishing, a picture of the 4 team members and a trophy which you can nab if you get into the room. Also a couple of leather benches by the options tv. Was going to add a Pool Table but this is enough for now. Shot below of me changing from 2 to 1 player.

http://www.steviegoodwin.plus.com/images/Untitled/WG17.png

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal