The sprites now display and everything seems to work.
This commit is contained in:
parent
93b7faa369
commit
e3596aeaa2
2 changed files with 138 additions and 27 deletions
|
@ -1,25 +1,25 @@
|
|||
/*
|
||||
Copyright (c) 2004-2020, Lode Vandevenne
|
||||
Copyright (c) 2004-2020, Lode Vandevenne
|
||||
|
||||
All rights reserved.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
|
@ -30,9 +30,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
using namespace QuickCG;
|
||||
|
||||
/*
|
||||
g++ *.cpp -lSDL -O3 -W -Wall -ansi -pedantic
|
||||
g++ *.cpp -lSDL
|
||||
*/
|
||||
g++ *.cpp -lSDL -O3 -W -Wall -ansi -pedantic
|
||||
g++ *.cpp -lSDL
|
||||
*/
|
||||
|
||||
|
||||
#define screenWidth 640
|
||||
|
@ -335,7 +335,11 @@ int main(int /*argc*/, char */*argv*/[])
|
|||
for(int i = 0; i < numSprites; i++)
|
||||
{
|
||||
spriteOrder[i] = i;
|
||||
spriteDistance[i] = ((posX - sprite[i].x) * (posX - sprite[i].x) + (posY - sprite[i].y) * (posY - sprite[i].y)); //sqrt not taken, unneeded
|
||||
spriteDistance[i] =
|
||||
((posX - sprite[i].x) *
|
||||
(posX - sprite[i].x) +
|
||||
(posY - sprite[i].y) *
|
||||
(posY - sprite[i].y)); //sqrt not taken, unneeded
|
||||
}
|
||||
sortSprites(spriteOrder, spriteDistance, numSprites);
|
||||
|
||||
|
@ -359,9 +363,9 @@ int main(int /*argc*/, char */*argv*/[])
|
|||
int spriteScreenX = int((w / 2) * (1 + transformX / transformY));
|
||||
|
||||
//parameters for scaling and moving the sprites
|
||||
#define uDiv 1
|
||||
#define vDiv 1
|
||||
#define vMove 0.0
|
||||
#define uDiv 1
|
||||
#define vDiv 1
|
||||
#define vMove 0.0
|
||||
int vMoveScreen = int(vMove / transformY);
|
||||
|
||||
//calculate height of the sprite on screen
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue