This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-04-17 15:00:49

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Variables vs lists

I'm making a 1s1s Pong project (lol some of you may remember I started it around a month ago, I'd forgotten about it until now  tongue ), and I'm storing the ball's coordinates with different variables (one for the x position, one for the y position, and one for the direction). Seeing as it's a 1s1s though, it lags considerably, and I wondered... Would it be faster to store the values in separate variables, or in one list with item 1 as the x value, item 2 as the y value, and item 3 as the direction? I'd imagine using variables would be faster, but I'd just like to check, since it could really do with some speeding up.

Last edited by RedRocker227 (2012-04-17 15:01:08)


Why

Offline

 

#2 2012-04-17 15:03:26

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Variables vs lists

IDK.  hmm  It could be a few bytes less, since it doesn't have to store the variable names. On the other hand, the item () of [] block is more.
I'm not sure it really makes a difference except in your programming style.

Offline

 

#3 2012-04-17 15:08:47

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: Variables vs lists

Okay. I'll probably just use lists then, since they're tidier. :3


Why

Offline

 

#4 2012-04-17 15:18:41

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Variables vs lists

Are they though? It isn't as easy to see what's what if they're just items in a list.

Offline

 

#5 2012-04-17 15:24:40

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: Variables vs lists

Yeah but with variables it's easy to accidentally set a different variable from the one you mean to, for example... Though I guess actually it's the same with lists, since you may enter the wrong number. I dunno, I can't see any differences other than lists are more "condensed" and are therefore tidier.  tongue


Why

Offline

 

Board footer