mirror of
https://github.com/sam-astro/Z-Sharp.git
synced 2025-12-13 09:02:10 +00:00
52 lines
1.1 KiB
Plaintext
52 lines
1.1 KiB
Plaintext
int SCREENW = 780
|
|
int SCREENH = 500
|
|
|
|
int scoreOne = 0
|
|
int scoreTwo = 0
|
|
Vec2 paddleScale = NVec2(16, 70)
|
|
|
|
func Main(input, in)
|
|
{
|
|
CPP.Graphics.Init("This is a pong game", SCREENW, SCREENH)
|
|
}
|
|
|
|
func Start()
|
|
{
|
|
float xPosBall = SCREENW / 2
|
|
float yPosBall = SCREENH / 2
|
|
Vec2 ballPosition = NVec2(xPosBall, yPosBall)
|
|
Vec2 ballScale = NVec2(16, 16)
|
|
|
|
Vec2 paddleScale = NVec2(16, 70)
|
|
|
|
float yPosPaddle = yPosBall - paddleScale.y / 2
|
|
|
|
Vec2 lPaddlePosition = NVec2(15, yPosPaddle)
|
|
|
|
float rOffset = SCREENW - 15
|
|
Vec2 rPaddlePosition = NVec2(rOffset, yPosPaddle)
|
|
|
|
global Sprite ballSprite = CPP.Graphics.Sprite("./square.png", ballPosition, ballScale, 0)
|
|
global Sprite lPaddle = CPP.Graphics.Sprite("./square.png", lPaddlePosition, paddleScale, 0)
|
|
global Sprite rPaddle = CPP.Graphics.Sprite("./square.png", rPaddlePosition, paddleScale, 0)
|
|
}
|
|
|
|
func Update()
|
|
{
|
|
Vec2 as = NVec2(16, 70)
|
|
print "updating"
|
|
|
|
if GetKey("W") == true
|
|
{
|
|
print "W"
|
|
as.x += 4
|
|
// lPaddle.position.y += 1
|
|
}
|
|
|
|
print as.x + " , " + as.y
|
|
|
|
CPP.Graphics.Draw(ballSprite)
|
|
CPP.Graphics.Draw(lPaddle)
|
|
CPP.Graphics.Draw(rPaddle)
|
|
}
|