Blame helianthus/main.c

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