#include <stdio.h>
#include "helianthus.h"
Sprite ball, brick1, brick2;
Sound beep;
void init() {
ball = createSpriteEx(200, 200, 64, 64);
spriteSetAnimation(ball, "data/sprite/breadball.png");
brick1 = createSpriteEx(200-32, 200+64, 64, 64);
spriteSetAnimation(brick1, "data/sprite/bricks.png");
spriteSetTintColor(brick1, rgb(0, 0, 1));
brick2 = createSpriteEx(200+32, 200+64, 64, 64);
spriteSetAnimation(brick2, "data/sprite/bricks.png");
spriteSetTintColor(brick2, rgba(1, 0, 1, 0.5));
beep = createSound("data/sound/beep.ogg");
}
void draw() {
double dt = worldGetTimeStep();
double speed = 100;
spritePointTo(ball, mouseX(), mouseY());
double x = spriteGetX(ball);
double y = spriteGetY(ball);
if (keyDown("left")) spriteSetX(ball, x - speed*dt);
if (keyDown("right")) spriteSetX(ball, x + speed*dt);
if (keyDown("up")) spriteSetY(ball, y - speed*dt);
if (keyDown("down")) spriteSetY(ball, y + speed*dt);
spriteSetSpeedAndDirection(ball, speed/2, spriteGetRotation(ball));
if (mouseWentDown("left")) soundPlay(beep, FALSE);
drawSprites();
}
int main() {
worldSetInit(&init);
worldSetDraw(&draw);
worldRun();
return 0;
}