Programming noob looking for more basic tutorials

So I’m pretty much completely new to programming. I really enjoyed the Hello World tutorials around, but I can’t seem to find many other basic tutorials dealing with images, interface, buttons and other basic features. I’m looking for more “practice” of basic functions with full explanations. When I try to learn stuff from the code examples, i’m pretty lost…

Anything out there? Thanks! [import]uid: 41923 topic_id: 7486 reply_id: 307486[/import]

I am in the same position as you… anybody that can help us, please do! [import]uid: 39628 topic_id: 7486 reply_id: 26489[/import]

Are there any specific examples or tutorials that you want? I might be able to make some, if you tell me what you want. [import]uid: 8782 topic_id: 7486 reply_id: 26490[/import]

the app i’m ultimately trying to build is a fitness app. basically i want to build timed workouts with logging and tracking.

the first thing i’m struggling with is creating a countdown/countup timer. i tried to figure it out form the timer and clock example app, yet i’m still struggling.

i understand the “timer.performWithDelay” function, but i’m not sure how to make it display in the format of “minutes”:“seconds”.“tenths of seconds”.

im sure its super simple, but like i said: im a total noob!!! [import]uid: 41923 topic_id: 7486 reply_id: 26502[/import]

hey robert! first off, congrats on everything and I love your game… Im in the position where I know what I want but not sure how to get it. what book did you get to originally learn lua? by the way im 15, still a kid like you :slight_smile: [import]uid: 39628 topic_id: 7486 reply_id: 26521[/import]

Hey, @b3nfreed, here’s a quick countdown timer example. Not the best code, but shows how to get it done:
[lua]–This code may not be the best or efficient way, it just shows how one might do it

–Local variables for minutes, seconds, and tenth of seconds
local minutes = 1
local seconds = 30
local tenseconds = 0

–Countdown timer variable
local countdownTimer

–Our display that will get updated showing the time
local timeDisplay = display.newText("",100,100,native.systemFont,30)

–Function that gets fired every tenth second.
local function time()
–The actual thing
–Nothing will be updated unless a second is up, in the which case there won’t be any tenth seconds
if (tenseconds == 0) then
–If there’s 0 ts (tenth seconds), change it to 9
tenseconds = 9
–Now that the ts are taken care of, if there’s 0 seconds…
if (seconds == 0) then
–Change it to 59 seconds and subtract a minute
seconds = 59
minutes = minutes - 1
else
–If there’s not 59 seconds, just subtract a second
seconds = seconds - 1
end
else
–This is if the ts is not at 0, just subtract 1 ts
tenseconds = tenseconds - 1
end

–Update the text display
timeDisplay.text = minutes…":"…seconds…"."…tenseconds

–If there’s no longer any minutes, seconds, or tenth seconds, stop the timer and show an alert
if (minutes == 0 and seconds == 0 and tenseconds == 0) then
timer.cancel(countdownTimer)
native.showAlert("",“Time’s up!”,{“OK”})
end
end

–Run the timer infinitely (it stops when time runs out), every 100ms which is 1/10th of a second.
countdownTimer = timer.performWithDelay(100,time,0)[/lua]
[import]uid: 8782 topic_id: 7486 reply_id: 26527[/import]

Hey @logster96, thanks! I actually didn’t read any books on lua or corona, just taught myself with examples and lots of forum questions. :slight_smile: I’d done web development before, and PHP is kinda similar to lua. Being a kid is a good thing.
[import]uid: 8782 topic_id: 7486 reply_id: 26528[/import]

yeah thats for sure! alright no rush on this and if its too complicated, let me know - but…

i was wondering how to create a path that is close to the edge of the screen and goes all the way around, with an arrow that follows the path. if you touch the right side of the screen, it goes right, if you touch the left side, it goes left, and its constantly moving unless you press right and its on the right side of the screen already and so on…

sorry kinda confusing : / [import]uid: 39628 topic_id: 7486 reply_id: 26529[/import]

the path looks like this but idk if this is the right way to do it - -

local outline = display.newRect( 15, 15, 290, 450 )
outline:setFillColor( 0, 0, 0 )
outline:setStrokeColor( 25, 0, 250 )
outline.strokeWidth = 2 [import]uid: 39628 topic_id: 7486 reply_id: 26530[/import]

Hmm, not quite sure how you would make it follow a path. I’m not an expert with it all, my (not-so) secret is that I learn just enough to get by. You could easily make it go left or right, I’m just not sure about following the path. Carlos posted some sample code where an object follows a bezier curve that might be helpful, I don’t know. [import]uid: 8782 topic_id: 7486 reply_id: 26531[/import]

okay… learning lua is tough. and im new to it but theres still simple stuff that im confused about like when i imported a board picture from sample codes, i did board.xScale = 1.7 but when I put in physics.setDrawMode(“hybrid”) the system did not recognize the extended part of the board as an object… any solution? [import]uid: 39628 topic_id: 7486 reply_id: 26532[/import]

WOW! thanks so much. i’m gonna take some time to pick this over and ask questions after that! thanks again!!! [import]uid: 41923 topic_id: 7486 reply_id: 26554[/import]

@logster96: Scaling physics objects is a known issue. You have to destroy and recreate the physics object to change the size. This is something I wish they would fix, as well as being able to change other physics properties (collision filters, density, etc.)

@b3nfreed: You’re very much welcome. If you have any questions, let me know. You (or anyone) can also email me at robert (at) naygames (dot) com
[import]uid: 8782 topic_id: 7486 reply_id: 26621[/import]

ok robert so i got it so far. now i’m trying to insert buttons to start, stop, and reset. i know i have to use the ui.lua and i tied to copy the code from the button code example.

i got the button to display but i’m sure the buttonHandler is wrong. care to help? THANKS!!!

here’s my code. (i also managed to display a “0” before the single digit seconds)

[lua]local ui = require(“ui”)

local buttonHandler = function( event )
timer.cancel(countdownTimer)
end

local button1 = ui.newButton{
default = “buttonBlue.png”,
over = “buttonBlueOver.png”,
onEvent = buttonHandler,
id = “button1”,
text = “Stop”,
font = “Trebuchet-BoldItalic”,
textColor = { 51, 51, 51, 255 },
size = 22,
emboss = true

}

–Local variables for minutes, seconds, and tenth of seconds
local minutes = 1
local seconds = 30
local tenseconds = 0

–Countdown timer variable
local countdownTimer

–Our display that will get updated showing the time
local timeDisplay = display.newText(“1:30.0”,100,100,native.systemFont,30)

–Function that gets fired every tenth second.
local function time()
–The actual thing
–Nothing will be updated unless a second is up, in the which case there won’t be any tenth seconds
if (tenseconds == 0) then
–If there’s 0 ts (tenth seconds), change it to 9
tenseconds = 9
–Now that the ts are taken care of, if there’s 0 seconds…
if (seconds == 0) then
–Change it to 59 seconds and subtract a minute
seconds = 59
minutes = minutes - 1
else
–If there’s not 59 seconds, just subtract a second
seconds = seconds - 1
end
else
–This is if the ts is not at 0, just subtract 1 ts
tenseconds = tenseconds - 1
end

–Update the text display

timeDisplay.text = minutes…":"…seconds…"."…tenseconds
if (minutes < 10) then timeDisplay.text = “0”…minutes…":"…seconds…"."…tenseconds end
if (seconds < 10) then timeDisplay.text = minutes…":"…“0”…seconds…"."…tenseconds end

–If there’s no longer any minutes, seconds, or tenth seconds, stop the timer and show an alert
if (minutes == 0 and seconds == 0 and tenseconds == 0) then
timer.cancel(countdownTimer)
native.showAlert("",“Time’s up!”,{“OK”})
end
end

–Run the timer infinitely (it stops when time runs out), every 100ms which is 1/10th of a second.
countdownTimer = timer.performWithDelay(100,time,0)

button1.x = 160; button1.y = 160[/lua] [import]uid: 41923 topic_id: 7486 reply_id: 26705[/import]

Try put

–Countdown timer variable
local countdownTimer

Above your button function! [import]uid: 10657 topic_id: 7486 reply_id: 26876[/import]

b3nfreed & logster,

I put together a list of all the Corona tutorials/lessons/screencasts I’m aware of since I was getting tired of digging through the forums and my cluttered bookmarks.

Here’s the link:
http://www.learningcorona.com/

Hopefully this is of some use. I’ll try to keep it up-to-date while I’m learning Corona. [import]uid: 25988 topic_id: 7486 reply_id: 26939[/import]

thank you very much! [import]uid: 39628 topic_id: 7486 reply_id: 26958[/import]

@Robert instead of calculating the time yourself, have you tried the os.difftime(t1,t2) which can provide you with the calculations only faster as the system does all the calculations for you. [import]uid: 3826 topic_id: 7486 reply_id: 27135[/import]