Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

trying to move diagonally on x & y axis

edited February 27 in Questions Posts: 58

I am trying to get the yellow ball to move diagonally.

Currently I am following along with @Ignatz beginner Codea guide and I am doing my own little challenges after each one of his sessions.

In ignatz code, the yellow ball moves horizontally along x axis:

function setup()


function draw()

    background(40, 40, 50)

I added y variable and y increment value, to have ball move diagonally:

function setup()


function draw()

    background(40, 40, 50)

Something I’m doing wrong, is causing Codea to ignore my y variable command resulting in no diagonal movement.

1) Do I have to concatenate the variables to get Codea to move the ball diagonally?

2) What am doing wrong that is causing Codea to ignore my y variable?



  • dave1707dave1707 Mod
    edited February 27 Posts: 9,415

    @tactfulgamer Codea isn’t ignoring your y variable, you’re just not using it. You’re adding 1 to it every draw cycle, but that’s all you’re doing with it. To get the ellipse to move diagonally, change it to ellipse(x,y,100) .

  • edited February 27 Posts: 58

    Thank you @dave1707

    So, that is what I was doing wrong, only setting variable for y in setup() and in draw() not within the ellipse itself. Interesting.

    That definitely worked, replacing 400 with y.

    but the concept as to how and why this works is escaping me :/

    I thought...
    the variables we place in setup() and in draw()... is what gives the ellipse instructions of where to go.

    I am confused as to how changing the 400 into a y, communicated to the ellipse in what direction to move.

    My beginner comprehension, understood.... that values placed within the ellipse parameters are to affect height, width and scale only? not the direction in which it is to travel?

    Maybe you can enlighten me with a newbie level explanation?

  • dave1707dave1707 Mod
    Posts: 9,415

    @tactfulgamer One place you can start is to look at the built in reference. You can find that by pressing the > in the upper left of the Codea project page. Or, if you’re in a project, tap the eye icon above the e key on the keyboard. Or at the top of this page is a Reference link. If you look in the reference under Graphics, you’ll see the ellipse command. If you tap on that it will give you info on how to use it. You’ll see that it uses the x,y,width,height variables, along with other uses. My suggestion is to look thru the reference just to become familiar with what’s there.

  • Thank you @dave1707

    I had no idea, the built in reference spoke about parameters within shapes. I will read up on it.

  • Posts: 193

    @tactfulgamer Judging from your past posts you may benefit from going through a generic lua programming tutorial such as

    You’ll have a much better understanding of the usage of variables and various language features / code structures that you’ll be better placed to understand the documentation.

    You’ll also be able to consider the reasons behind decisions made in Codea specific tutorials as opposed to working out what the code actually means.

  • edited March 1 Posts: 58

    @Steppers thank you.

    I appreciate the website. The first few pages are explained in a super simple approach. Thanks. I’m hoping I can follow along in the Codea editor, if not I’ll just use ripple.

    Just the other day I purchased three courses on Udemy:
    (By far - the best one on Udemy)

  • Posts: 2,348
    @tactfulgamer - there is plenty of information and quite a few simple demos on the wiki, accessed from Codea website menu, and the forum contains a wealth of small demos if you are searching for anything specific. Might be an idea sometime to make a list of these or add them to the wiki.
  • Posts: 58

    @Bri_G Good idea, thank you.

    I will check out the wiki.

    Appreciate your suggestions. At moment, @Ignatz Codea beginner guide, seems to be providing me understanding. I’ll definitely jump onto your advise once finished here.

Sign In or Register to comment.