Skip to content

Commit

Permalink
Fiicode Hackathon
Browse files Browse the repository at this point in the history
  • Loading branch information
antonioganea committed May 5, 2018
1 parent c12cacd commit 491c07a
Show file tree
Hide file tree
Showing 48 changed files with 513 additions and 147 deletions.
1 change: 1 addition & 0 deletions Compound.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<Add directory="include/Gui" />
<Add directory="include/Debug" />
<Add directory="include/Scripting" />
<Add directory="lib/lua" />
</Compiler>
<Linker>
<Add directory="C:/Users/Sapard/workspace/compound/lib/lua" />
Expand Down
Binary file added data/sounds/dead.wav
Binary file not shown.
Binary file added data/sounds/shoot-old1.wav
Binary file not shown.
Binary file added data/sounds/shoot.wav
Binary file not shown.
Binary file added data/sounds/shoot33.mp3
Binary file not shown.
Binary file added data/sounds/shootsafe.wav
Binary file not shown.
Binary file added data/sounds/song.mp3
Binary file not shown.
Binary file modified data/textures/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/textures/10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/textures/11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/textures/12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/textures/13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/textures/14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/textures/15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/textures/16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/textures/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/textures/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/textures/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/textures/5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/textures/6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/textures/7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/textures/8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/textures/9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/textures/Thumbs.db
Binary file not shown.
Binary file modified data/textures/arena.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/textures/projectile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/textures/spaceship.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions include/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#define APP_NAME "Compound"
#define APP_VERSION "v0.5"

#define WINDOW_WIDTH 1200
#define WINDOW_HEIGHT 800
#define WINDOW_WIDTH 1600
#define WINDOW_HEIGHT 1000

#endif // CONFIG_H_INCLUDED
4 changes: 4 additions & 0 deletions include/Gui/GuiEditField.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ class GuiEditField
void setString( std::string str );
char * getString();
void checkType( sf::Event::KeyEvent keyEvent );
void checkText( sf::Event::TextEvent textEvent );
bool checkClick( sf::Event::MouseButtonEvent buttonEvent );
bool checkHover( sf::Event::MouseMoveEvent moveEvent );
sf::RectangleShape shape;
sf::Text text;
void draw();
bool highlighted;

bool ipField;

char stringBuffer[16];
protected:
Expand Down
2 changes: 2 additions & 0 deletions include/Networking/SyncManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class SyncManager

static sf::Uint16 getServerEventCode( const char * eventName );
static std::string getClientEventName( sf::Uint16 eventCode );

static std::string nickname;
protected:

private:
Expand Down
1 change: 1 addition & 0 deletions include/Scripting/LuaConsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class LuaConsole

static void triggerClientEvent( const char * eventName );
static void triggerKeyPressEvent( sf::Uint16 key );
static void triggerKeyReleaseEvent( sf::Uint16 key );
static void triggerTypedEvent( char typedChar );
static void triggerClientEvent( sf::Uint16 eventCode, sf::Packet restOfPacket );
static void triggerUpdateEvent();
Expand Down
3 changes: 2 additions & 1 deletion include/Stage/ConnectMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class ConnectMenu : public Stage
void draw();

sf::RectangleShape arena;
GuiEditField * field;
GuiEditField * ipField;
GuiEditField * nameField;
protected:

private:
Expand Down
Binary file added libgcc_s_seh-1.dll
Binary file not shown.
Binary file added libstdc++-6.dll
Binary file not shown.
Binary file added libwinpthread-1.dll
Binary file not shown.
Binary file added openal32.dll
Binary file not shown.
206 changes: 206 additions & 0 deletions resources/crystal/client-jet.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
print("Script loading - Virus Invaders 2.0");

local width, height = GetWindowSize()

--[[
RegisterClientEvent("invaders:clientTest")
AddEventHandler("invaders:clientTest",function(arg1, arg2, arg3, arg4)
print("Server to client event triggering test successful!" .. tostring(arg1) .. " " .. tostring(arg2) .. " " .. tostring(arg3) .. " " .. tostring(arg4) )
end)
]]

RegisterClientEvent("invaders:spawnCritter")
AddEventHandler("invaders:spawnCritter",function(id, texture, x, y)
--print("invaders:spawnCritter " .. tostring(math.floor(id)) .. " " .. tostring(texture) .. " 0x" .. tostring(code) .. " " .. tostring(math.floor(x)) )
if type(code) == "number" then
code = math.floor(code)
end
spawnCritter( math.floor(id), texture, code, math.floor(x) )
end)

local critters = {}

function spawnCritter( id, texture, x, y )
newCritter = CreateObject()
SetTexture( newCritter, texture )
SetPosition ( newCritter, x, y )
SetFriction ( newCritter, 0.2 )

critters[id] = {
["object"] = newCritter,
["timer"] = 0,
["behaviour"] = math.random(1,3)
}
end

local it = 1

function killCritter(k)
KillObject(critters[k].object)
critters[k] = nil
end

local projectiles = {}
local projectileID = 1

function shootProjectile( turret, targetCritter )
local tx, ty = GetPosition( turret )

local newProjectile = CreateObject()
SetPosition(newProjectile,tx,ty)
SetTexture(newProjectile,"projectile.png")
SetVelocity(newProjectile,0,-5)

projectiles[projectileID] = { ["object"] = newProjectile, ["target"] = targetCritter }
projectileID = projectileID + 1
end

-- Turret & projectiles --
local myTurret = CreateObject()
SetTexture( myTurret, "spaceship.png" )
SetPosition( myTurret, width/2, height/2 )
SetFriction( myTurret, 0.2 )
RegisterAsServerObject( myTurret )
turretDirection = 90

function rotateTurret( angle )
turretDirection = angle
SetRotation( myTurret, 90-turretDirection )
end

function computeVelocity( multiplier )
local rad_dir = math.rad(turretDirection)
local xVelocity = math.cos(rad_dir) * multiplier
local yVelocity = math.sin(rad_dir) * multiplier
return xVelocity, -yVelocity
end

function thrustTurret( multiplier )
local rad_dir = math.rad(turretDirection)
local xVelocity = math.cos(rad_dir) * multiplier
local yVelocity = math.sin(rad_dir) * multiplier
SetVelocity(myTurret, xVelocity, -yVelocity)
--print ( "Thrust : direction " .. turretDirection .. " vel : " .. xVelocity .. " " .. yVelocity )
end

rotationAcceleration = 0
rotationSpeed = 0



-- W 22
-- A 0
-- S 18
-- D 3
-- Space 57

Keys = { W=22, A=0, S=18, D=3, Space=57 }

PressedKeys = {}

AddEventHandler( "onKeyPress", function( keyCode )
PressedKeys[keyCode] = true
--[[
if keyCode == Keys.W then
thrustTurret(10)
elseif keyCode == Keys.S then
thrustTurret(-10)
elseif keyCode == Keys.D then
rotationAcceleration = 1
elseif keyCode == Keys.A then
rotationAcceleration = -1
end]]

if keyCode == Keys.Space then
spawnCritter(it,math.random(1,8)..".png",math.random(0,width),math.random(0,height))
it = it + 1
end
end)

AddEventHandler( "onKeyRelease", function( keyCode )
PressedKeys[keyCode] = false
--[[
if keyCode == Keys.W then
thrustTurret(10)
elseif keyCode == Keys.S then
thrustTurret(-10)
elseif keyCode == Keys.D then
rotationAcceleration = 1
elseif keyCode == Keys.A then
rotationAcceleration = -1
end]]
end)


local spawnTimer = 0
local clocker = false

RegisterClientEvent("invaders:setClock")
AddEventHandler("invaders:setClock", function()
clocker = true
print("HEY")
end)

TriggerServerEvent("invaders:askForClock")

extraBordering = 100 -- extra space for out of borders deletions

AddEventHandler( "onFrame", function( )

if clocker then
spawnTimer = spawnTimer + 1
if spawnTimer >= 180 then
TriggerServerEvent("invaders:spawnTimer")
spawnTimer = 0
end
end

-- Critter update
for k,v in pairs ( critters ) do
local cx,cy = GetPosition(v.object)
if ( cy > height + extraBordering or cy < -extraBordering or cx > width+extraBordering or cx < -extraBordering ) then
killCritter(k)
print("Critter out of borders")
else
v.timer = v.timer + 1
if ( v.timer == 60 ) then
v.timer = 0
SetVelocity(v.object,0,5)
end
end
end


-- Turret Direction
local newdir = turretDirection
rotationSpeed = rotationSpeed + rotationAcceleration
newdir = newdir + rotationSpeed
rotationSpeed = rotationSpeed - rotationSpeed*0.2
rotateTurret( newdir )

-- Controls
if PressedKeys[Keys.W] then
thrustTurret(5)
elseif PressedKeys[Keys.S] then
thrustTurret(-5)
end
if PressedKeys[Keys.A] then
rotationAcceleration = 1.1
elseif PressedKeys[Keys.D] then
rotationAcceleration = -1.1
else
rotationAcceleration = 0
end
end)

-- Scoreboard
newLabel = CreateLabel( 0, 0, "Antonio Ganea" )
SetFontSize(newLabel,32)
SetColor(newLabel,1)

newLabel = CreateLabel( 0, 50, "Radu Tache" )
SetFontSize(newLabel,32)
SetColor(newLabel,1)

print("Script loaded! Virus Invaders 2.0")
Loading

0 comments on commit 491c07a

Please sign in to comment.