Skip to content

Commit

Permalink
Fixed bug with Sprites, Created installer
Browse files Browse the repository at this point in the history
Sprites would not center at initialization, instead only after changing a second time

Installer for adding Slang interpreter to 'Program Files' directory in Windows
  • Loading branch information
sam-astro committed Jan 15, 2022
1 parent 3f6e04b commit 687b9c6
Show file tree
Hide file tree
Showing 8 changed files with 806 additions and 33 deletions.
785 changes: 785 additions & 0 deletions Slang-Installer/Slang-Installer.vdproj

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions Slang.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ VisualStudioVersion = 17.0.31612.314
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Slang", "Slang\Slang.vcxproj", "{D5F150F8-1F83-41EB-A195-1B5C3CA9322A}"
EndProject
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "Slang-Installer", "Slang-Installer\Slang-Installer.vdproj", "{42EA0B7A-2068-4065-B9EB-041F32933A66}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Expand All @@ -21,6 +23,11 @@ Global
{D5F150F8-1F83-41EB-A195-1B5C3CA9322A}.Release|x64.Build.0 = Release|x64
{D5F150F8-1F83-41EB-A195-1B5C3CA9322A}.Release|x86.ActiveCfg = Release|Win32
{D5F150F8-1F83-41EB-A195-1B5C3CA9322A}.Release|x86.Build.0 = Release|Win32
{42EA0B7A-2068-4065-B9EB-041F32933A66}.Debug|x64.ActiveCfg = Release
{42EA0B7A-2068-4065-B9EB-041F32933A66}.Debug|x64.Build.0 = Release
{42EA0B7A-2068-4065-B9EB-041F32933A66}.Debug|x86.ActiveCfg = Debug
{42EA0B7A-2068-4065-B9EB-041F32933A66}.Release|x64.ActiveCfg = Release
{42EA0B7A-2068-4065-B9EB-041F32933A66}.Release|x86.ActiveCfg = Release
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
11 changes: 0 additions & 11 deletions Slang/CMakeLists.txt

This file was deleted.

2 changes: 1 addition & 1 deletion Slang/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ int main(int argc, char* argv[])
}
else
{
LogCriticalError("No script provided! Please drag and drop .SLG file over interpreter executable file, or provide it's path as a command-line argument.");
LogWarning("No script provided! Please drag and drop .SLG file over interpreter executable file, or provide it's path as a command-line argument.");
system("pause");
exit(1);
}
Expand Down
2 changes: 0 additions & 2 deletions Slang/Pong-Project/script.slg
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ func Start()

Vec2 ballScale = NVec2(10, 10)
Vec2 ballPos = centerOfScreen
ballPos -= ballScale

Vec2 paddleScale = NVec2(4, 70)
float yPosPaddle = centerOfScreen.y
yPosPaddle -= paddleScale.y / 2

Vec2 lPaddlePosition = NVec2(15, yPosPaddle)
global Vec2 lPaddleTargetPosition = NVec2(15, yPosPaddle)
Expand Down
6 changes: 0 additions & 6 deletions Slang/Slang.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,6 @@
<ClInclude Include="SLB.h" />
<ClInclude Include="strops.h" />
</ItemGroup>
<ItemGroup>
<None Include="script.slg" />
</ItemGroup>
<ItemGroup>
<Text Include="CMakeLists.txt" />
</ItemGroup>
<ItemGroup>
<Image Include="icon.ico" />
<Image Include="tut\hello_world.bmp" />
Expand Down
6 changes: 0 additions & 6 deletions Slang/Slang.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="script.slg" />
</ItemGroup>
<ItemGroup>
<Text Include="CMakeLists.txt" />
</ItemGroup>
<ItemGroup>
<Image Include="tut\hello_world.bmp">
<Filter>Source Files</Filter>
Expand Down
20 changes: 13 additions & 7 deletions Slang/graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "strops.h"
#include "main.h"
#include <SDL.h>
#include <SDL_image.h>
#include <SDL_image.h>
#include <stdio.h>
#include <chrono>
#include <SDL.h>
Expand Down Expand Up @@ -189,7 +189,7 @@ class Vec2
{
x *= rhs;
y *= rhs;

return *this;
}

Expand Down Expand Up @@ -360,6 +360,9 @@ class Sprite
rect.y = static_cast<int>(position.y);
rect.w = scale.x;
rect.h = scale.y;
// Centers
rect.x = position.x - (rect.w / 2);
rect.y = position.y - (rect.h / 2);

Load();
}
Expand All @@ -383,10 +386,10 @@ class Sprite

int Draw()
{
SDL_RenderCopy(gRenderer, texture, NULL, &rect);
// Centers
rect.x = position.x - (rect.w / 2);
rect.y = position.y - (rect.h / 2);
SDL_RenderCopy(gRenderer, texture, NULL, &rect);
return 0;
}

Expand Down Expand Up @@ -493,6 +496,9 @@ class Sprite
else if (oper == "/=")
scale.y /= AnyAsFloat(otherVal);
}
// Centers
rect.x = position.x - (rect.w / 2);
rect.y = position.y - (rect.h / 2);
return *this;
}

Expand Down Expand Up @@ -534,8 +540,8 @@ class Text
scale.y = rect.h;

// Centers
position.x = rect.x - (rect.w / 2);
position.y = rect.y - (rect.h / 2);
rect.x = position.x - (rect.w / 2);
rect.y = position.y - (rect.h / 2);

SDL_FreeSurface(surface);
return 0;
Expand All @@ -556,8 +562,8 @@ class Text
scale.y = rect.h;

// Centers
position.x = rect.x - (rect.w / 2);
position.y = rect.y - (rect.h / 2);
rect.x = position.x - (rect.w / 2);
rect.y = position.y - (rect.h / 2);

SDL_FreeSurface(surface);
return 0;
Expand Down

0 comments on commit 687b9c6

Please sign in to comment.