[NEWBIE REQUIRES HELP]

Pixilang programming language
Post Reply
RayureBob
Posts: 3
Joined: Fri Jun 08, 2018 9:47 pm

[NEWBIE REQUIRES HELP]

Post by RayureBob » Sat Dec 15, 2018 4:59 am

Hi. Sorry for the weak title.

I'm trying to get a grasp on Pixilang's basics, and encountered a problem I cannot seem to figure out.

Here's the code I used, and here's the result

Code: Select all

set_pixel_size( WINDOW_XSIZE / 480 )
resize( get_screen(), WINDOW_XSIZE, WINDOW_YSIZE )

$x = WINDOW_XSIZE
$y = 0
speed = 10

while 1 {
	//line(xpoint1, ypoint1, xpoint2, ypoint2
	line(0, 0, $x, $y, RED)
	
	transp(32)
	clear(BLACK)
	transp(255)
	
//sup droite vers inf droite
	if $x == WINDOW_XSIZE {
		if $y != WINDOW_YSIZE {
			$y = $y + speed
		}
	}
	
//inf droite vers inf gauche
	if $y == WINDOW_YSIZE {
		if $x > -WINDOW_XSIZE {
			$x = $x - speed
		}
	}
	
//inf gauche vers sup gauche
	if $x == -WINDOW_XSIZE {
		if $y != -WINDOW_YSIZE {
			$y = $y - speed
		}
	}
	
//sup gauche vers sup droite
	if $y == -WINDOW_YSIZE {
		if $x != WINDOW_XSIZE {
			$x = $x + speed
		}
	}
	
	
	frame()
}
If I don't touch the screen size, and if I don't use a speed value greater than 10, it works as intended.
However if I change one or the other, this happens

The few things I understand aren't helping me solving the problem. Please help :cry:

Edit
To be more precise, it seems like the closer to zero get $x, the smaller gets the value of speed

EDIT2
Nevermind I found the problem, it was just baddly written conditions.

Post Reply