Page 1 of 1

Cubes

Posted: Mon Aug 19, 2013 1:59 pm
by naburus
I started to get know the engine. But i have problems.
For example: Can't save the "log.txt",
and what i don't understand in this code: why the cubes move away?

Source code: http://pastebin.com/iKDmysDe

love.graphics.rectangle("fill", x, y, 10, 10 )
The loop runs at 20 times (this is OK), but why the cubes move?
I want only to draw a straight line, about cubes.

Sorry for my bad englisth.

Re: Cubes

Posted: Mon Aug 19, 2013 2:02 pm
by MPQC

Code: Select all

     Windows XP: C:\Documents and Settings\user\Application Data\LOVE\ or %appdata%\LOVE\
    Windows Vista and 7: C:\Users\user\AppData\Roaming\LOVE or %appdata%\LOVE\
    Linux: $XDG_DATA_HOME/love/ or ~/.local/share/love/
    Mac: /Users/user/Library/Application Support/LOVE/
You probably are saving your file, but it's being saved to one of the above locations (where saves go), rather than your love directory. Check the above paths first.

As for why the cube moves away, in your love.draw function:

Code: Select all

 while i  <= 20 do
                i = i + 1
                x = x + 10     
                love.graphics.rectangle("fill", x, y, 10, 10 ) 
                love.graphics.print("In x varible: "..x, 400, 10)
        end     
You keep incrementing x, so it'll keep moving away.

Re: Cubes

Posted: Mon Aug 19, 2013 2:11 pm
by naburus
You right, file saving works but another directory. Ty :)

Sry my cubes dont moving, only missing. When my loop finish, all cubes gone. Why?

Re: Cubes

Posted: Mon Aug 19, 2013 2:15 pm
by MPQC
naburus wrote:You right, file saving works but another directory. Ty :)

Sry my cubes dont moving, only missing. When my loop finish, all cubes gone. Why?
If you look at the code, every single frame you increase the x position 20 times (10 * 20 = 200 pixels). So within 10 frames (1/6th of a second), your object is pretty much guarenteed to be off the screen.

Re: Cubes

Posted: Mon Aug 19, 2013 2:24 pm
by naburus
Now is see, ty.