Basic questions.


Sorry to post again so soon, I hate filling your nice forums up with my trash but I have a couple of questions that I cannot seem to find the answer to and I know you guys will know.

1: Doesn’t redrawing the screen 60x a second make Codea very inefficient?

Example:- as I’m continuing to try and learn lua today I made myself a tiled background (floor if you like) to a possible game and it occurred to me that it seems a waste of power to redraw this 60x a second, why not draw it the once and only redraw sprites that move? (I apologise if its a dumb question)

2: use of = and ==

I did a lot of basic programming back in the 80’s and 90’s, mostly Atari, C64, ZX81, Amos basic type stuff and all of them used =. ie setting a variable was ‘let x=1’, using an ‘if’ was ‘if z=2 then…’ Whereas Codea seems to swap and change. From the guides I have been following it seems that some things use = and some use ==. as a beginner I am finding it hard to remember which is which and tbh it would be simpler if they used = for everything or == for everything or am I missing something?

3: To import my own graphics, do the images have to be a certain size or graphics format? or will it load anything, ie gif, jpg, png, 10x134, 103x34, 300x400?

@SteveNoob don’t worry at all about posting questions :slight_smile:

1 - Not necessarily (infact quite the opposite), the screen redrawing fast means you can achieve really smooth movements and animations. But your code can certainly affect the effeciency of this :slight_smile:

2 - They’re very different, = is the assignment operator and == is the equality operator .

-- assignment 
local var1 = 1
local var2 = 2

-- equality

local areEqual = var1 == var2

if areEqual == true then
print("not equal")

3 - Off the top of my head, size doesn’t matter too much although the is a hard limit but this is over 2000px so i wouldn’t worry.

Vector art should be .svg (or possibly PDF but not sure on this one)

Normal bitmap art .jpg .png (and possibly more but these should cover most if not all bitmaps you’d want to import :slight_smile: )

Edit: 2048px is the maximum size a single image

You can also use .spritepack files which have multiple images

Thank you very much :slight_smile:

@Stevenoob the == sign is only ever used in an if statement or a while statement such as

If foo == bar then return true end

The other way it can be used is in print, like this:

local n = math.random(4,6)
print(n == 6)

This use returns a boolean stating if n equals 6 or not.