Before we start writing our first line of code I want you to show how I do plan an app.
First let’s do some scribbles.
ou are not good at drawing? That doesn’t matter. We do not want to create an high class artwork. We want to get an overview of our app: we elements our app consists of, where are the elements placed, what about other resolutions and screen rations (like smartphone vs. tablet).
If we know the elects of our app, we can already think about structuring our code.
So, to start scribbling I recommend to use my device mockups from the download section and print them on paper.
My scribbles look like this:
Elements of the App
As the scribbles show we have three main components in this app:
- the word clock
- the weather forecast
- the settings window
If you find such logical components like the ones above, it does make sense to write them apart from the rest of the app logic. In this case we will write a module for each of this part.
In general a module consists of one or several Lua files that can be referenced (required) to in our main program.
This technique has several advantages:
- we avoid cluttered code. For example: we isolate the word clock logic into its very own module, apart from the main app logic and the weather and settings logic.
- it makes the code reusable for other projects
- it is easier to maintain: a bug in the weather data? So we need to check the weather module.
- it is robust and elegant 🙂
Ok, now we know: beside our main.lua (which every Corona project must have) we need three modules for the word clock, the weather and the settings screen.
What do we need for a word clock
Let’s think about the word clock module now. Try to imagine what properties and functions we need to display such a word clock.
You do not need to think of every aspect now. I just want you to think into the module and get a feeling for a bit of planning.
I’m gonna help here:
Since this a clock we surely need a property that has the current time.
Since the minutes and hours are printed as text we need the hours and the minutes of the current time.
Maybe the seconds too? We don’t know at this moment, but this is okay.
Think about how to display the clock. In this case this a raster of single letters. So we need to save not just one value but 12 by 10 values (our word clock is built of 12 columns and 10 rows of single letters). So we need to store 120 letters.
Furthermore we need to save the state for each letter: whether it is glowing or not.
Smells like we need to use tables here.
What functions do we need?
We must be able to control each letter if it is glowing or not. So maybe a function like SetLetterOn( numberOfLetter ) might be a good idea.
Also we need a function that converts the current time into glowing letters. But somehow we have to check the current hours/minutes and translate them to our letter matrix.
You get the idea?
I recommend to write your ideas down. If work on these ideas for some time, you will get a kind of roadmap which helps you along the project.
You learned some very basic techniques to plan a new project. I really recommend to make at least some scribbles and write down ideas, thoughts and questions to your project.
The bigger your projects get, the more important it is to make a good planning. If you want to know more about writing and planning a project, I recommend reading my articles about Writing a game concept.
You will also find a game concept template in the downloads section. And the premium members do get real life game concept of my BeliDash game which has been approved by the Belimed AG!
In the next part of this course, we finally start coding – yay!