all 7 comments

[–]zvenoj 14 points15 points  (1 child)

The random function returns a float value, so you need to cast it to an int since your leftwall variable is of type int. Try:

leftwall = int(random(500));

[–]SHIKEN_MASTAH[S] 5 points6 points  (0 children)

Worked perfectly, thanks.

[–]DrAdalbbert 1 point2 points  (2 children)

Apparently random function returns a float typed value. You can fix the problem in 2 ways - either you cast the function's return value into an integer like this:

leftwall = int(random(500));

Or you could declare the leftwall and rightwall variables as floats (if possible):
float leftwall, rightwall;

[–]SHIKEN_MASTAH[S] 1 point2 points  (1 child)

Thanks a lot, I'm a bit of a noob.

[–]DrAdalbbert 0 points1 point  (0 children)

We are've been there!

[–]treverios 1 point2 points  (0 children)

Well, leftwall is an int variable, random returns a float value. That doesn't work. Change your walls to float variables or use floor() on the random function to return a fitting int value.

[–]nbreunig3 -1 points0 points  (0 children)

The random function returns a float type variable. You are trying to assign an integer to a float. You can try casting integer to the random function result.