shmups.system11.org

Shmups Forum
 
* FAQ    * Search
 * Register  * Login 
It is currently Tue Dec 07, 2021 2:11 pm View unanswered posts
View active topics



Post new topic Reply to topic  [ 43 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: How to implement overshoot on enemy arrival?
PostPosted: Sat Jun 19, 2021 2:17 pm 


User avatar

Joined: 13 Sep 2019
Posts: 416
DyingIsFun wrote:
I use simple geometric checks to see if a bullet is within a certain radius or rectangular area around my player or enemy. It's pretty straightforward to determine if a point is in a circle or rectangle without full fledged physics engine :D. I actually found these simple geometric checks to be more performant for me than when I did have BoxColliders on player, bullets, and enemies (which is how I originally started my prototype).


Does your geometric check only exist of mutliply, subract, or adding math ?, then your good.
If you use sqrt function, you are doing it the wrong way.


Top
 Offline Profile  
 
 Post subject: Re: How to implement overshoot on enemy arrival?
PostPosted: Sat Jun 19, 2021 3:44 pm 


User avatar

Joined: 31 Aug 2009
Posts: 7781
Location: 東京都杉並区
heli wrote:
Trap15 you did not answer my question

What was your question then, because as shown I have looked at the code for itoa. If you mean the machine code, sure I've seen that too, yes. It's pretty much what you would expect from looking at the C version.

heli wrote:
divide is very slow, not recommended for use in main loop.

You're kidding right? Divide hasn't been slow for PCs for nearly 30 years. Even when it was slow, it was "60~100 times addition", which even if it was true in the modern day is literally meaningless amounts of time. Even on 80s CPUs you can use divide instructions just fine.

heli wrote:
You using itoa in your main loop for the score ?, that it has to do with video game mechanic.

Going back to thinking about software design, running something like this a single time per frame is absolutely reasonable. What else are you going to do, keep every digit in a separate byte and manually carry additions when you add to score? That's going to hurt performance way way worse than 20 divides and modulos every frame (though, again, going back to decreasing frequency, you only need to do this once each time score updates, and cache the results, so you're doing it only when necessary).
_________________
@trap0xf | daifukkat.su/blog | scores | FIRE LANCER
<S.Yagawa> I like the challenge of "doing the impossible" with older hardware, and pushing it as far as it can go.


Top
 Offline Profile  
 
 Post subject: Re: How to implement overshoot on enemy arrival?
PostPosted: Sat Jun 19, 2021 9:42 pm 


User avatar

Joined: 18 Feb 2011
Posts: 6543
Location: Denmarku
heli wrote:
divide is very slow, not recommended for use in main loop.

What do you think a "main loop" is?


Top
 Offline Profile  
 
 Post subject: Re: How to implement overshoot on enemy arrival?
PostPosted: Sun Jun 20, 2021 3:31 pm 


User avatar

Joined: 13 Sep 2019
Posts: 416
trap15 wrote:
heli wrote:
Trap15 you did not answer my question

What else are you going to do, keep every digit in a separate byte and manually carry additions when you add to score? That's going to hurt performance way way worse than 20 divides and modulos every frame (though, again, going back to decreasing frequency, you only need to do this once each time score updates, and cache the results, so you're doing it only when necessary).


Exactly, there are 4 vertices for each polygon, so i increase score by 4 only.
If you do update once in a while, you get once in a while a slow frame.

So you saying multiple modulos in 1 frame is faster then increasing a unsigned int with 4 ?

Sumez wrote:
What do you think a "main loop" is?


I should have sayd : inner loop, or loop core.


Top
 Offline Profile  
 
 Post subject: Re: How to implement overshoot on enemy arrival?
PostPosted: Sun Jun 20, 2021 3:41 pm 


User avatar

Joined: 13 Sep 2019
Posts: 416
I love to see a game from you.
Just to see the system-requirements of your game, just for fun.


Top
 Offline Profile  
 
 Post subject: Re: How to implement overshoot on enemy arrival?
PostPosted: Sun Jun 20, 2021 4:07 pm 


User avatar

Joined: 31 Aug 2009
Posts: 7781
Location: 東京都杉並区
heli wrote:
I love to see a game from you.
Just to see the system-requirements of your game, just for fun.

http://firelancer.ws/

It runs on a 3.072MHz CPU from 1999.

heli wrote:
Exactly, there are 4 vertices for each polygon, so i increase score by 4 only.

This is gravely concerning to read, just by the way. How are you handling carry between digits? And, do you really think something like 500 cycles (way more than doing the itoa conversion would take, but let's just get exaggerated for point's sake) is going to affect any single frame in any significant way? A 1GHz CPU can run over 16 million cycles in one frame.
_________________
@trap0xf | daifukkat.su/blog | scores | FIRE LANCER
<S.Yagawa> I like the challenge of "doing the impossible" with older hardware, and pushing it as far as it can go.


Top
 Offline Profile  
 
 Post subject: Re: How to implement overshoot on enemy arrival?
PostPosted: Mon Jun 21, 2021 2:36 pm 


User avatar

Joined: 13 Sep 2019
Posts: 416
It inreases until 10, then it set back to 0, and count 1 more for the next number.
If you compare it to itoa :
itoa does all numbers all the time,
my function dont, it is possible, when the score is 9999999999999999999, it will take compute all the characters for 1 point increase, just like itoa does all the time, only itoa cant handle this big scores.
+ if it take all characters it is still faster.

And thank you i have a plan to increase speed, since i just wanted to tell you :
You always need to keep your frames the same speed, without peaks,
you better waste some time on things all the time then more slowdown for 1 frame.
So i was thinking, i could try if i could compute only 1 number per frame, and increase the rest when no scoring is done, maybe it will slowdown things per frame, the slowest frame will be almost equal to the fastest frame.

So you are saying you using all sine cosine and other math functions to make a game for a 1999 PC ?
How do you aim the tanks ?, with atanf function ?


Top
 Offline Profile  
 
 Post subject: Re: How to implement overshoot on enemy arrival?
PostPosted: Mon Jun 21, 2021 3:53 pm 


User avatar

Joined: 31 Aug 2009
Posts: 7781
Location: 東京都杉並区
heli wrote:
It inreases until 10, then it set back to 0, and count 1 more for the next number.
If you compare it to itoa :
itoa does all numbers all the time,
my function dont, it is possible, when the score is 9999999999999999999, it will take compute all the characters for 1 point increase, just like itoa does all the time, only itoa cant handle this big scores.
+ if it take all characters it is still faster.

Seems like a pain to deal with, but you do you. Of course itoa has limitations, but there's nothing wrong with it if it fits the bill. If the extra couple hundred cycles (again, exaggeration for making the point) are the breaking point between running full speed and not, there's something seriously slow elsewhere that's more worthwhile to optimize.

heli wrote:
You always need to keep your frames the same speed, without peaks,
you better waste some time on things all the time then more slowdown for 1 frame.
So i was thinking, i could try if i could compute only 1 number per frame, and increase the rest when no scoring is done, maybe it will slowdown things per frame, the slowest frame will be almost equal to the fastest frame.

So I take it you don't know about the concept of a frame limiter or something then. Spending more or less time per frame doesn't matter as long as your total time in the frame is less than a frame's length, because your frame beginning and ending is quantized to the frame rate. If you had to make sure every frame's code lasted the same exact length to avoid slowdown or speedups, I don't think modern software could ever exist.

heli wrote:
So you are saying you using all sine cosine and other math functions to make a game for a 1999 PC ?
How do you aim the tanks ?, with atanf function ?

It's for a handheld console, not PC. As a result, I don't have these math library functions anyways, but they're not that different. Yes I use arctangent for aiming, but yes I wrote my own implementation. Because I need to, because my platform only lets me run 50 thousand cycles per frame.
_________________
@trap0xf | daifukkat.su/blog | scores | FIRE LANCER
<S.Yagawa> I like the challenge of "doing the impossible" with older hardware, and pushing it as far as it can go.


Top
 Offline Profile  
 
 Post subject: Re: How to implement overshoot on enemy arrival?
PostPosted: Mon Jun 21, 2021 3:58 pm 


User avatar

Joined: 13 Sep 2019
Posts: 416
Glad we finally agree.
Can i have your code for the aiming ?, or give me a hint how u made it ?


Top
 Offline Profile  
 
 Post subject: Re: How to implement overshoot on enemy arrival?
PostPosted: Mon Jun 21, 2021 4:02 pm 


User avatar

Joined: 13 Sep 2019
Posts: 416
trap15 wrote:
So I take it you don't know about the concept of a frame limiter or something then. Spending more or less time per frame doesn't matter as long as your total time in the frame is less than a frame's length, because your frame beginning and ending is quantized to the frame rate. If you had to make sure every frame's code lasted the same exact length to avoid slowdown or speedups, I don't think modern software could ever exist.


You might have all the peaks in 1 frame.
Computers are great, like you say, handheld hardware is not.
I like to have my code without librarys so i can run on anything like handheld.
Building hardware a bit, looking forward to make a handheld game console one day,
i am very intrested in how old games work, whats in those ROMs for nice tricks to make it run on a 80s chip.
I cant read it, i just play for inspiration, battle garegga had me inspired to make the score like this.


Top
 Offline Profile  
 
 Post subject: Re: How to implement overshoot on enemy arrival?
PostPosted: Mon Jun 21, 2021 4:33 pm 


User avatar

Joined: 31 Aug 2009
Posts: 7781
Location: 東京都杉並区
heli wrote:
You might have all the peaks in 1 frame.

This is very unlikely, and mostly not worth serious consideration unless profiling says otherwise. Single frame hitches basically go unnoticed anyways. Again, a 500 cycle penalty per frame, even every frame, is not going to matter.

heli wrote:
Can i have your code for the aiming ?, or give me a hint how u made it ?

Just made a program that pre-calculates a table of atan values to include into my code, then a function that uses the table as if it was the function. Do some research on the implementation of atan2 and using arctangent to turn coordinate offsets into angles, it's very worthwhile.
_________________
@trap0xf | daifukkat.su/blog | scores | FIRE LANCER
<S.Yagawa> I like the challenge of "doing the impossible" with older hardware, and pushing it as far as it can go.


Top
 Offline Profile  
 
 Post subject: Re: How to implement overshoot on enemy arrival?
PostPosted: Tue Jun 22, 2021 3:42 pm 


User avatar

Joined: 13 Sep 2019
Posts: 416
Thank you.


Top
 Offline Profile  
 
 Post subject: Re: How to implement overshoot on enemy arrival?
PostPosted: Thu Jul 22, 2021 1:20 pm 


User avatar

Joined: 13 Sep 2019
Posts: 416
Trap15 i use this piece of code to aim my turrets :
https://en.wikipedia.org/wiki/Fast_inverse_square_root

Get normal values with that, then pass it in the render-matrix.
For aiming i use vectors that i move, no rotations.


Top
 Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 43 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Space Pilot 3K template by Jakob Persson
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group