real beginner question

Okay, now I’ve got a simple game app. It runs through once and you get a score and then it ends. How do I start it again at the beginning so I can save and add to the score? I remember when I was 10 I once programmed something in basic, and you could goto a specific line. I looked but didn’t see anything like that in Corona.

Thanks for your help [import]uid: 96383 topic_id: 16603 reply_id: 316603[/import]

Are you familiar with the learning corona website?

http://www.learningcorona.com/

There are a few tutorials on there that deal with screen or scene changes. It sounds like you are at a point where you need to figure out how to add that to your app.

[import]uid: 67839 topic_id: 16603 reply_id: 62028[/import]

I do not know how long ago you were 10, but definitely know that in programming GOTO has been deemed evil and most new languages do not have the GOTO function. Instead they encourage other ways to look at achieving the same without GOTO.

so there are several ways,

mostly it will be to structure your game in a function (more like GOSUB) so what you do it have an endless loop that will call these functions.

something like

while isPlaying==true do
playGame()
– This will somewhere affect the variable isPlaying and make it false and therefore the loop will exit
loop

now I do not know how you have structured your game, but the idea will be similar… even if you were to use any other language / framework, you will have to think slightly differently.

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 16603 reply_id: 62029[/import]

it should be clear what JayantV explains.
but here are some more examples:

BASIC is an *imperative* language…

10 variable = 0  
20 variable = variable + 1  
30 print variable  
40 goto 20  

when the program is started, the “reading head” interprets the code line by line, just like plain HTML.

LUA, for instance, uses procedural (or structural) programming: the code is organized in procedures (aka subroutines, methods, functions), that are made up of chunks of imperative code which can be called from anywhere inside the code:

function addNumbers (a1,b1)  
 var c = a1 + b1  
 return c   
end  
  
function multiplyNumbers (a2,b2)  
 var c = a2 \* b2  
 return c  
end  
  
function addAndMultiplyAndSquareRoot (a3,b3)  
 var c = addNumbers (a3,b3)  
 var d = multiplyNumbers (a3,b3)  
 var e = math.sqrt (c + d)  
 return e  
end  
  
var myNumber = addAndMultiplyAndSquareRoot (5,3)  
print (myNumber) -- output: 4,79583152331272  

As you can see, the first two functions are used in the third to do the (lil’ silly) math. Usually you should create a function if you need a piece of code more than once. That is the case in most programs anyone writes today (and especially in games).

You need a moving ball?
Add n to the x- and y-coordinates on every frame inside a moveBall-function.
You want to check user input?
Write an onTouch-function that listens to tap events constantly.

Another program paradigm is OOP (object-oriented programming, e.g. used in obj-C and JAVA) where you create classes that take particular tasks of your program. Each class contains a set of it’s own functions.
In LUA you can use modules, which is not(!) OOP, but comparable…

so take a look at the posted link and start learning corona/LUA - FTW!

cheers
-finefin
[import]uid: 70635 topic_id: 16603 reply_id: 62122[/import]