Re: problems with some functions, any suggestions?

2015-04-28 Thread AudioGames . net Forum — Developers room : Kyleman123 via Audiogames-reflector


  


Re: problems with some functions, any suggestions?

yes you should use floats. it will allow for much more preciseness.for example: in pythonex1. using integers8 /3 = 2obviously 2 is correct but its not the whole answer.x2 using floats8.0 / 3.0 = 2.66...5that is way more accurate and a big difference. im not sure if bgt handles this diffrently but i can only assume its about the same. just think if something came out like 5.915826384694628. the answer youd get using integers would still be 5 but youd be off by almost 1. which is a whole crap of a lot when talk in terms of shooting games.

URL: http://forum.audiogames.net/viewtopic.php?pid=214025#p214025




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: problems with some functions, any suggestions?

2015-04-28 Thread AudioGames . net Forum — Developers room : Dranelement via Audiogames-reflector


  


Re: problems with some functions, any suggestions?

Hi, all the variables that store important numbers are doubles, which are very precise. The only things that are integers are the values returned by the functions, which are used to handle different cases.

URL: http://forum.audiogames.net/viewtopic.php?pid=214028#p214028




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: problems with some functions, any suggestions?

2015-04-27 Thread AudioGames . net Forum — Developers room : tward via Audiogames-reflector


  


Re: problems with some functions, any suggestions?

@Dranelement, I havent had the time to go through your code to any extent, but one thing that strikes me as wrong as you are declaring your variables as int. You should never use integer variables for this type of calculation as you will lose precision and accuracy by doing so. You should be declaring them as floating point variables, float, in order to retain the accuracy you want/need for this type of calculation.

URL: http://forum.audiogames.net/viewtopic.php?pid=213947#p213947




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: problems with some functions, any suggestions?

2015-04-27 Thread AudioGames . net Forum — Developers room : Dranelement via Audiogames-reflector


  


Re: problems with some functions, any suggestions?

Hi, actualy the only things that are int are the values the function is returning. Some of the peramiters of the function are actually variables that get changed based on the input. I would have used pointers, but for some reason bgt only lets you use those in classes, so...

URL: http://forum.audiogames.net/viewtopic.php?pid=213962#p213962




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

problems with some functions, any suggestions?

2015-04-27 Thread AudioGames . net Forum — Developers room : Dranelement via Audiogames-reflector


  


problems with some functions, any suggestions?

Hi, I have been struggling to get a couple of functions in my latest project to do what theyre supposed to, and was wondering if anyone could offer any suggestions.Basically whats supposed to happen is this. When you fire a gun, the game checks to see if it intersects each enemy, which, in code, is a circle with a radius of 2. I have a function that checks whether a line intersects a circle, which can be found here.https://www.dropbox.com/s/59hreb10098wvu9/LCI.bgt?dl=1This seems to work, but Im having problems when I try to get the closest enemy with a function. When the function gets called, Im getting a divide by 0 error in line 7 of the function in the db link. Im not sure why this is though, as that can only happen if the distance between you and the enemy is 0.Does anyone have any suggestions as to why this might be happening? The code for the funct
 ion is below:double iEX, iEY, i2EX, i2EY;int rIndex = -1;for (int index = 0; index  this.pl.level.enemies.length; index++) {  if (getCircleIntersection(this.pl.x+1, this.pl.y+1, newX, newY, this.pl.level.enemies[index].x, this.pl.level.enemies[index].y, this.pl.level.enemies[index].radius, iEX, iEY, i2EX, i2EY) == 1) {if (square_root((this.pl.x-iEX)^2+(this.pl.y-iEY)^2)  distance) {  distance = square_root((this.pl.x-iEX)^2+(this.pl.y-iEY)^2);  rIndex = index;}else if (square_root((this.pl.x-i2EX)^2+(t
 his.pl.y-i2EY)^2)  distance) {  distance = square_root((this.pl.x-i2EX)^2+(this.pl.y-i2EY)^2);rIndex=index;}}  else if(getCircleIntersection(this.pl.x, this.pl.y, newX, newY, this.pl.level.enemies[index].x, this.pl.level.enemies[index].y, this.pl.level.enemies[index].radius, iEX, iEY, i2EX, i2EY) == 2) {if (square_root((this.pl.x-iEX)^2+(this.pl.y-iEY)^2)  distance) {  distance = square_root((this.pl.x-iEX)^2+(this.pl.y-iEY)^2);  rIndex = index;  
 p;  }  }}return rIndex;  }I feel like Im missing something obvious, but like I said. I really have absolutely no idea.

URL: http://forum.audiogames.net/viewtopic.php?pid=213941#p213941




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector