Cubes

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
naburus
Prole
Posts: 5
Joined: Fri Aug 16, 2013 1:50 pm

Cubes

Post 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.
User avatar
MPQC
Citizen
Posts: 65
Joined: Fri Jun 28, 2013 2:45 pm

Re: Cubes

Post 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.
naburus
Prole
Posts: 5
Joined: Fri Aug 16, 2013 1:50 pm

Re: Cubes

Post 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?
User avatar
MPQC
Citizen
Posts: 65
Joined: Fri Jun 28, 2013 2:45 pm

Re: Cubes

Post 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.
naburus
Prole
Posts: 5
Joined: Fri Aug 16, 2013 1:50 pm

Re: Cubes

Post by naburus »

Now is see, ty.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest