im working on directRd and i have seen no problems with aliasing, so at least thats not a issue,
but are you guys saying its best to recheck all the warnings to see if it is really needed to make that conversion, and if it is use a cast (im guessing a cast is like putting (int) before the variable)?
as you can see under here there are quite some warnings,
now the & warnings will be gone in seconds

, but the others, is this ammount a issue?
(dont worry about the error, just put that in to get the warnings, did not know how to see them otherwise

)
warnings:
1>c:\myprojects\template\devmaster_intro-to-c-tmpl83.00c_oct14\game.cpp(254): warning C4244: '+=' : conversion from 'float' to 'int', possible loss of data
1>c:\myprojects\template\devmaster_intro-to-c-tmpl83.00c_oct14\game.cpp(283): warning C4244: '+=' : conversion from 'float' to 'int', possible loss of data
1>c:\myprojects\template\devmaster_intro-to-c-tmpl83.00c_oct14\game.cpp(285): warning C4554: '&' : check operator precedence for possible error; use parentheses to clarify precedence
1>c:\myprojects\template\devmaster_intro-to-c-tmpl83.00c_oct14\game.cpp(302): warning C4554: '&' : check operator precedence for possible error; use parentheses to clarify precedence
1>c:\myprojects\template\devmaster_intro-to-c-tmpl83.00c_oct14\game.cpp(303): warning C4244: 'argument' : conversion from 'int' to 'float', possible loss of data
1>c:\myprojects\template\devmaster_intro-to-c-tmpl83.00c_oct14\game.cpp(308): warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
1>c:\myprojects\template\devmaster_intro-to-c-tmpl83.00c_oct14\game.cpp(309): warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
1>c:\myprojects\template\devmaster_intro-to-c-tmpl83.00c_oct14\game.cpp(312): warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
1>c:\myprojects\template\devmaster_intro-to-c-tmpl83.00c_oct14\game.cpp(313): warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
1>c:\myprojects\template\devmaster_intro-to-c-tmpl83.00c_oct14\game.cpp(314): warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
1>c:\myprojects\template\devmaster_intro-to-c-tmpl83.00c_oct14\game.cpp(315): warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
1>c:\myprojects\template\devmaster_intro-to-c-tmpl83.00c_oct14\game.cpp(335): warning C4554: '&' : check operator precedence for possible error; use parentheses to clarify precedence
1>c:\myprojects\template\devmaster_intro-to-c-tmpl83.00c_oct14\game.cpp(376): warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
1>c:\myprojects\template\devmaster_intro-to-c-tmpl83.00c_oct14\game.cpp(377): warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
1>c:\myprojects\template\devmaster_intro-to-c-tmpl83.00c_oct14\game.cpp(378): warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
1>c:\myprojects\template\devmaster_intro-to-c-tmpl83.00c_oct14\game.cpp(379): warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
1>c:\myprojects\template\devmaster_intro-to-c-tmpl83.00c_oct14\game.cpp(457): warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
1>c:\myprojects\template\devmaster_intro-to-c-tmpl83.00c_oct14\game.cpp(462): warning C4244: 'argument' : conversion from 'int' to 'float', possible loss of data
1>c:\myprojects\template\devmaster_intro-to-c-tmpl83.00c_oct14\game.cpp(462): warning C4244: 'argument' : conversion from 'int' to 'float', possible loss of data
1>c:\myprojects\template\devmaster_intro-to-c-tmpl83.00c_oct14\game.cpp(463): warning C4244: 'argument' : conversion from 'float' to 'int', possible loss of data
1>c:\myprojects\template\devmaster_intro-to-c-tmpl83.00c_oct14\game.cpp(463): warning C4244: 'argument' : conversion from 'float' to 'int', possible loss of data
1>c:\myprojects\template\devmaster_intro-to-c-tmpl83.00c_oct14\game.cpp(473): warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
1>c:\myprojects\template\devmaster_intro-to-c-tmpl83.00c_oct14\game.cpp(474): warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
1>c:\myprojects\template\devmaster_intro-to-c-tmpl83.00c_oct14\game.cpp(487): warning C4244: 'argument' : conversion from 'float' to 'int', possible loss of data
1>c:\myprojects\template\devmaster_intro-to-c-tmpl83.00c_oct14\game.cpp(487): warning C4244: 'argument' : conversion from 'float' to 'int', possible loss of data
1>c:\myprojects\template\devmaster_intro-to-c-tmpl83.00c_oct14\game.cpp(508): error C2065: 'a' : undeclared identifier
1>c:\myprojects\template\devmaster_intro-to-c-tmpl83.00c_oct14\game.cpp(508): error C2146: syntax error : missing ';' before identifier 'i'
1>c:\myprojects\template\devmaster_intro-to-c-tmpl83.00c_oct14\game.cpp(518): warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
under here my code untill this point, still need to clean some things as i was converting from max and min x/y values to tilecollision, so thats not finished yet.
// Template, major revision 3
// IGAD/NHTV - Jacco Bikker - 2006-2009
#include "string.h"
#include "surface.h"
#include "stdlib.h"
#include "template.h"
#include "game.h"
using namespace Tmpl8;
// sprites
Sprite poppetje( new Surface("assets/poppetje.BMP"), 1);
Sprite bullet( new Surface("assets/bullet.BMP"), 1);
Sprite bubble1( new Surface("assets/bubble1.BMP"), 1);
//background
Surface* tileSet[9];
int landTile[11][40] = {{2, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,1},
{6, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6},
{6, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6},
{6, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6},
{6, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6},
{6, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6},
{6, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6},
{6, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6},
{6, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6},
{6, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6},
{3, 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,4}};
int floory = 640;
// player variables
float xplayer = 320;
float yplayer = 200;
float dyplayer;
int xspeed = 3;
int playerheigth = 30;
int playertilex1;
int playertilex2;
int playertiley1;
int playertiley2;
bool left;
bool right;
bool up;
bool down;
// bullet variables
float xbullet[6];
float ybullet[6];
float x1bullet[6];
float y1bullet[6];
float x2bullet[6];
float y2bullet[6];
float dxbullet[6];
float dybullet[6];
float speed = 10;
float steps[6];
int bullet1[6]; // 1 is false 2 is true
int i=0;
bool shot = false;
int shotbreak = 0;
int shoottime = 10;
// bubble variables
int bubble1x[6]; //= 100;
int bubble1y[6]; //= 50;
int drawbubble[6]; //= true;
float bubble1dy[6]; //= 1;
float bubble1ddy[6]; //= 0.1;
float bubble1ddx[6]; //= 0.1;
float bubble1dx[6]; //= 1;
float maxyspeed[6]; //= 12;
float maxxspeed[6];
int bubblecount;
float bubbledist;
int bubbledistcount;
float bubbledistfix;
float bubblefraction;
float bubblexdist;
float bubbleydist;
int bubbleradius[6];
int bubbledoubler[6];
// collision variables
int distance;
//level variables
int deadbubblecount;
int bubblestokill;
int lvl;
// timer variables
long long milliseconds_now() {
static LARGE_INTEGER s_frequency;
static BOOL s_use_qpc = QueryPerformanceFrequency(&s_frequency);
if (s_use_qpc) {
LARGE_INTEGER now;
QueryPerformanceCounter(&now);
return (1000LL * now.QuadPart) / s_frequency.QuadPart;
} else {
return GetTickCount();
}
}
void Game::Init()
{
// background
tileSet[0] = new Surface( "assets/background1.BMP" );
tileSet[1] = new Surface( "assets/background2.BMP" );
tileSet[2] = new Surface( "assets/background3.BMP" );
tileSet[3] = new Surface( "assets/background4.BMP" );
tileSet[4] = new Surface( "assets/background5.BMP" );
tileSet[5] = new Surface( "assets/background6.BMP" );
tileSet[6] = new Surface( "assets/background7.BMP" );
tileSet[7] = new Surface( "assets/background8.BMP" );
// bullet inits
bullet1[0]=1;
bullet1[1]=1;
bullet1[2]=1;
bullet1[3]=1;
bullet1[4]=1;
bullet1[5]=1;
// bubbles inits
bubble1x[0]=100;
bubble1x[1]=200;
bubble1x[2]=300;
bubble1y[0]=50;
bubble1y[1]=50;
bubble1y[2]=50;
drawbubble[0]=2;
drawbubble[1]=2;
drawbubble[2]=2;
bubble1dy[0]=1;
bubble1dy[1]=1;
bubble1dy[2]=1;
bubble1ddy[0]=0.1;
bubble1ddy[1]=0.1;
bubble1ddy[2]=0.1;
bubble1ddy[3]=0.1;
bubble1ddy[4]=0.1;
bubble1ddy[5]=0.1;
bubble1ddx[0]=0.00;
bubble1ddx[1]=0.00;
bubble1ddx[2]=0.00;
bubble1ddx[3]=0.00;
bubble1ddx[4]=0.00;
bubble1ddx[5]=0.00;
bubble1dx[0]=1;
bubble1dx[1]=1;
bubble1dx[2]=1;
maxyspeed[0]=12;
maxyspeed[1]=12;
maxyspeed[2]=12;
maxyspeed[3]=12;
maxyspeed[4]=12;
maxyspeed[5]=12;
bubblestokill = 3;
maxxspeed[0] = 5;
maxxspeed[1] = 5;
maxxspeed[2] = 5;
maxxspeed[3] = 5;
maxxspeed[4] = 5;
maxxspeed[5] = 5;
bubbleradius[0] = 20;
bubbleradius[1] = 20;
bubbleradius[2] = 20;
bubbleradius[3] = 20;
bubbleradius[4] = 20;
bubbleradius[5] = 20;
bubbledoubler[0] = 0;
bubbledoubler[1] = 0;
bubbledoubler[2] = 0;
bubbledoubler[3] = 0;
bubbledoubler[4] = 0;
bubbledoubler[5] = 0;
// lvl inits
lvl = 1;
}
int mousex, mousey;
void Game::MouseMove( unsigned int x, unsigned int y )
{
mousex = x;
mousey = y;
}
void Game::Tick( float a_DT )
{
long long start = milliseconds_now();
//background
m_Screen->Clear( 0 );
for (int indexX = 0; indexX <= 39; indexX++)
{
for (int indexY = 0; indexY <= 10; indexY++)
{
int tile = landTile[indexY][indexX];
tileSet[tile]->CopyTo( m_Screen, indexX * 20, indexY * 60 );
}
}
// bubblecalculator
while (bubblecount<bubblestokill)
{
if(drawbubble[bubblecount]==2)
{
/*
if ((bubble1dy[bubblecount] < 0.01) & (bubble1dy[bubblecount] > -0.01))
{
bubble1dy[bubblecount] = 0;
}
*/
bubble1y[bubblecount] += bubble1dy[bubblecount];
bubble1dy[bubblecount] += bubble1ddy[bubblecount];
// to prevent alls from jumping straight up and down
if ((bubble1dx[bubblecount] < 1) & (bubble1dx[bubblecount] > 0))
{
bubble1dx[bubblecount] += bubble1ddx[bubblecount];
}
if ((bubble1dx[bubblecount] < 0) & (bubble1dx[bubblecount] > -1))
{
bubble1dx[bubblecount] -= bubble1ddx[bubblecount];
}
if ((bubble1dy[bubblecount] >maxyspeed[bubblecount]))
{
bubble1dy[bubblecount] = maxyspeed[bubblecount];
}
if ((bubble1dy[bubblecount] <-maxyspeed[bubblecount]))
{
bubble1dy[bubblecount] = -maxyspeed[bubblecount];
}
if (bubble1y[bubblecount] < 20)
{
bubble1y[bubblecount] = 40 - bubble1y[bubblecount];
bubble1dy[bubblecount]= -bubble1dy[bubblecount];
}
bubble1x[bubblecount] += bubble1dx[bubblecount];
if(((bubble1x[bubblecount]> (780 - 2 * bubbleradius[bubblecount]) )& (bubble1dx[bubblecount] > 0))|| ((bubble1x[bubblecount] <20) & bubble1dx[bubblecount] <0))
{
bubble1dx[bubblecount] = -bubble1dx[bubblecount];
}
if (bubble1y[bubblecount] > (floory- 2*bubbleradius[bubblecount]))
{
bubble1y[bubblecount]= floory - 2*bubbleradius[bubblecount];
bubble1dy[bubblecount] = -bubble1dy[bubblecount];
}
bubble1.Draw(bubble1x[bubblecount],bubble1y[bubblecount], m_Screen);
}
while(bubbledistcount<bubblestokill)
{
if (bubbledistcount!=bubblecount)
{
if(drawbubble[bubblecount] == 2 & drawbubble[bubblecount] == 2)
bubbledist = sqrtf((((bubble1x[bubbledistcount]+bubbleradius[bubbledistcount] )-(bubble1x[bubblecount]+bubbleradius[bubblecount]))*(((bubble1x[bubbledistcount]+bubbleradius[bubbledistcount])-(bubble1x[bubblecount]+bubbleradius[bubblecount])))+(((bubble1y[bubbledistcount]+bubbleradius[bubbledistcount])-(bubble1y[bubblecount]+bubbleradius[bubblecount]))*((bubble1y[bubbledistcount]+bubbleradius[bubbledistcount])-(bubble1y[bubblecount]+bubbleradius[bubblecount])))));
if (bubbledist<(bubbleradius[bubblecount]+bubbleradius[bubbledistcount]))
{
bubbledistfix = bubbleradius[bubblecount]+bubbleradius[bubbledistcount]-bubbledist;
bubblefraction = bubbledistfix / bubbledist;
bubblexdist =(bubble1x[bubbledistcount]+bubbleradius[bubbledistcount])-(bubble1x[bubblecount]+bubbleradius[bubblecount]);
bubbleydist =(bubble1y[bubbledistcount]+bubbleradius[bubbledistcount])-(bubble1y[bubblecount]+bubbleradius[bubblecount]);
bubble1dx[bubbledistcount] = bubble1dx[bubbledistcount] + 2.5 * (bubblefraction * bubblexdist * 0.5);
bubble1dy[bubbledistcount] = bubble1dy[bubbledistcount] + 2.5 * (bubblefraction * bubbleydist * 0.5);
bubble1dx[bubblecount] = -bubble1dx[bubblecount] - (bubblefraction * bubblexdist * -0.5);
bubble1dy[bubblecount] = -bubble1dy[bubblecount] - (bubblefraction * bubbleydist * -0.5);
bubbledoubler[bubblecount]++;
if ((bubble1dy[bubblecount] >maxyspeed[bubblecount]))
{
bubble1dy[bubblecount] = maxyspeed[bubblecount];
}
if ((bubble1dy[bubblecount] <-maxyspeed[bubblecount]))
{
bubble1dy[bubblecount] = -maxyspeed[bubblecount];
}
if ((bubble1dy[bubbledistcount] >maxyspeed[bubblecount]))
{
bubble1dy[bubbledistcount] = maxyspeed[bubblecount];
}
if ((bubble1dy[bubbledistcount] <-maxyspeed[bubblecount]))
{
bubble1dy[bubbledistcount] = -maxyspeed[bubblecount];
}
if(bubbledoubler[bubbledistcount] == 10 & bubblestokill<6)
{
bubble1x[bubblestokill] = bubble1x[bubbledistcount] + 2*bubbleradius[bubbledistcount];
bubble1y[bubblestokill] = bubble1y[bubbledistcount] + 2*bubbleradius[bubbledistcount];
bubble1dx[bubblestokill] = - bubble1dx[bubbledistcount];
bubble1dy[bubblestokill] = bubble1dy[bubbledistcount];
bubble1ddy[bubblestokill] = bubble1ddy[bubbledistcount];
drawbubble[bubblestokill] = 2;
bubblestokill++;
bubbledoubler[bubbledistcount]=0;
}
if(bubble1dx[bubbledistcount]>maxxspeed[bubbledistcount])
{
bubble1dx[bubbledistcount] = maxxspeed[bubbledistcount];
}
if(bubble1dx[bubblecount]>maxxspeed[bubblecount])
{
bubble1dx[bubblecount] = maxxspeed[bubblecount];
}
if(bubble1dx[bubbledistcount]<-maxxspeed[bubbledistcount])
{
bubble1dx[bubbledistcount] = -maxxspeed[bubbledistcount];
}
if(bubble1dx[bubblecount]<-maxxspeed[bubblecount])
{
bubble1dx[bubblecount] = -maxxspeed[bubblecount];
}
}
}
bubbledistcount++;
}
bubbledistcount = 0;
bubblecount++;
}
bubblecount = 0;
// landTile[13][66]
playertilex1 = (xplayer-1)/20;
playertilex2 = (xplayer+20)/20;
playertiley1 = (yplayer/60);
playertiley2 = ((yplayer + 20)/60);
if ((
landTile[playertiley1 ][playertilex1] == 6 ||
landTile[playertiley1 ][playertilex1] == 3) &
(landTile[playertiley2 ][playertilex1] == 6 ||
landTile[playertiley2 ][playertilex1] == 3)
)
{
left = false;
}
else
{
left = true;
}
if ((
landTile[playertiley1 ][playertilex2] == 6 ||
landTile[playertiley1 ][playertilex2] == 4 )&
(landTile[playertiley2 ][playertilex2] == 6 ||
landTile[playertiley2 ][playertilex2] == 4)
)
{
right = false;
}
else
{
right = true;
}
if ((
landTile[playertiley2 ][playertilex1] == 5 ||
landTile[playertiley2 ][playertilex1] == 4 ||
landTile[playertiley2 ][playertilex1] == 3) &
(landTile[playertiley2 ][playertilex2] == 5 ||
landTile[playertiley2 ][playertilex2] == 4 ||
landTile[playertiley2 ][playertilex2] == 3)
)
{
down = false;
}
else
{
down = true;
}
if(GetAsyncKeyState( 0x44 )) // D
{
if (right == true)
{
xplayer=xplayer + xspeed;
}
}
if(GetAsyncKeyState( 0x41 )) // A
{
if (left == true)
{
xplayer = xplayer - xspeed;
}
}
if((GetAsyncKeyState( VK_SPACE ))&(down == false))
{
dyplayer = 10;
}
if(dyplayer>0)
{
yplayer -= dyplayer;
dyplayer -= 0.1;
}
if (down == true)
{
yplayer += 5;
}
if(yplayer > (floory - playerheigth))
{
yplayer = (floory - playerheigth);
}
m_Screen->Line( xplayer, yplayer, mousex, mousey, 0xff0000 );
poppetje.Draw(xplayer,yplayer, m_Screen);
// bullet calculator
while(i<6)
{
if((GetAsyncKeyState( MK_LBUTTON )||(GetAsyncKeyState( WM_LBUTTONDOWN))) & (bullet1[i]==1) & (shotbreak > shoottime))
{
bullet1[i] = 2;
x2bullet[i] = mousex;
y2bullet[i] = mousey;
x1bullet[i] = xplayer;
y1bullet[i] = yplayer;
steps[i] = ((sqrtf(((x2bullet[i]-x1bullet[i])*(x2bullet[i]-x1bullet[i]))+((y2bullet[i]-y1bullet[i])*(y2bullet[i]-y1bullet[i]))))/speed);
dxbullet[i]=(x2bullet[i]-x1bullet[i])/steps[i];
dybullet[i]=(y2bullet[i]-y1bullet[i])/steps[i];
xbullet[i] = x1bullet[i];
ybullet[i] = y1bullet[i];
shot = true;
shotbreak=0;
}
if(bullet1[i] == 2)
{
bullet.Draw(xbullet[i],ybullet[i], m_Screen);
xbullet[i] += dxbullet[i];
ybullet[i] += dybullet[i];
if (xbullet[i]<0||xbullet[i]>1300||ybullet[i]<0||ybullet[i]>900)
{
bullet1[i]=1;
xbullet[i]=0;
ybullet[i]=0;
}
}
if (shot == false)
{
i++;
}
else
{
i = 7;
}
}
a
i=0;
shot = false;
// making sure player wont shoot all bullets at once (+ giving possibilities to different kind of weapons)
shotbreak++;
// hitcalculator
while(i<6)
{
while (bubblecount < bubblestokill)
{
distance = sqrtf(((bubble1x[bubblecount]+bubbleradius[bubblecount])-(xbullet[i]+2))*((bubble1x[bubblecount]+bubbleradius[bubblecount])-(xbullet[i]+2))+((bubble1y[bubblecount]+bubbleradius[bubblecount])-(ybullet[i]+2))*((bubble1y[bubblecount]+bubbleradius[bubblecount])-(ybullet[i]+2)));
if(distance<27)
{
drawbubble[bubblecount] = 1;
xbullet[i] = 0;
ybullet[i] = 0;
bubble1x[bubblecount] = 0;
bubble1y[bubblecount] = 0;
}
bubblecount++;
}
i++;
bubblecount=0;
}
i=0;
deadbubblecount = (drawbubble[0]+drawbubble[1]+drawbubble[2]+drawbubble[3]+drawbubble[4]+drawbubble[5]);
if(deadbubblecount <= bubblestokill)
{
if(lvl == 1)
{
lvl2 ();
}
else if(lvl == 2)
{
lvl3 ();
}
}
if((deadbubblecount==bubblestokill) & (lvl == 3))
{
lvl3 ();
}
long long elapsed = milliseconds_now() - start;
// printf ("time: %f\n", elapsed );
if((elapsed>0)&(elapsed<1000/60))
{
// Sleep ((1000/60)-elapsed);
}
}