Fixed xrel, yrel having the wrong value
This commit is contained in:
@@ -5,19 +5,21 @@ var SPEED: int const = 10;
|
||||
|
||||
//variables
|
||||
var parent: opaque = null;
|
||||
var x: int = 50;
|
||||
var y: int = 50;
|
||||
var posX: int = 50;
|
||||
var posY: int = 50;
|
||||
var WIDTH: int const = 100;
|
||||
var HEIGHT: int const = 100;
|
||||
|
||||
var xspeed: int = 0;
|
||||
var yspeed: int = 0;
|
||||
|
||||
//accessors - variables are private, functions are public
|
||||
fn getX(node: opaque) {
|
||||
return x;
|
||||
return posX;
|
||||
}
|
||||
|
||||
fn getY(node: opaque) {
|
||||
return y;
|
||||
return posY;
|
||||
}
|
||||
|
||||
//lifecycle functions
|
||||
@@ -29,8 +31,8 @@ fn onInit(node: opaque) {
|
||||
}
|
||||
|
||||
fn onStep(node: opaque) {
|
||||
x += xspeed;
|
||||
y += yspeed;
|
||||
posX += xspeed;
|
||||
posY += yspeed;
|
||||
}
|
||||
|
||||
fn onFree(node: opaque) {
|
||||
@@ -53,7 +55,7 @@ fn onDraw(node: opaque) {
|
||||
py = 0;
|
||||
}
|
||||
|
||||
node.drawNode(x + px, y + py, 100, 100);
|
||||
node.drawNode(posX + px, posY + py, WIDTH, HEIGHT);
|
||||
}
|
||||
|
||||
//event functions
|
||||
@@ -102,22 +104,22 @@ fn onKeyUp(node: opaque, event: string) {
|
||||
}
|
||||
|
||||
fn onMouseMotion(node: opaque, x: int, y: int, xrel: int, yrel: int) {
|
||||
print "entity.toy:onMouseMotion()";
|
||||
//TODO: mouse motion
|
||||
// print "entity.toy:onMouseMotion(" + string x + ", " + string y + ", " + string xrel + ", " + string yrel + ")";
|
||||
}
|
||||
|
||||
fn onMouseButtonDown(node: opaque, x: int, y: int, button: string) {
|
||||
print "entity.toy:onMouseButtonDown()";
|
||||
//TODO: mouse button down
|
||||
// print "entity.toy:onMouseButtonDown(" + string x + ", " + string y + ", " + button + ")";
|
||||
|
||||
//jump to pos
|
||||
posX = x - WIDTH / 2;
|
||||
posY = y - HEIGHT / 2;
|
||||
}
|
||||
|
||||
fn onMouseButtonUp(node: opaque, x: int, y: int, button: string) {
|
||||
print "entity.toy:onMouseButtonUp()";
|
||||
//TODO: mouse button up
|
||||
// print "entity.toy:onMouseButtonUp(" + string x + ", " + string y + ", " + button + ")";
|
||||
}
|
||||
|
||||
fn onMouseWheel(node: opaque, x: int, y: int) {
|
||||
print "entity.toy:onMouseWheel()";
|
||||
//TODO: mouse wheel
|
||||
fn onMouseWheel(node: opaque, xrel: int, yrel: int) {
|
||||
// print "entity.toy:onMouseWheel(" + string xrel + ", " + string yrel + ")";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user