Discuss Scratch

_Elektron_
Scratcher
93 posts

How to use lists in a game?

Can someone please explain to me how to use list effeciently in a game? My aim to make a simplistic game..
duckboycool
Scratcher
1000+ posts

How to use lists in a game?

This is very general. Lists can be used for just about anything that uses data (which is about 99.9% of projects give or take a few halves)

Last edited by duckboycool (Feb. 14, 2017 00:21:56)

BY147258369
Scratcher
1000+ posts

How to use lists in a game?

I like to use lists in a way in which I can add a scoreboard. Lists usually aren't used in “simplistic” games.


Edit: I was ninja'd by 32 seconds.

Last edited by BY147258369 (Feb. 14, 2017 00:22:33)

hammer965
Scratcher
100+ posts

How to use lists in a game?


When you create a list you can add new records to the bottom of the list.

You can also insert records at specific points in the list so you should be able to, for example arrange the scores into numerical order each time a new score is added.

If you want to have a name and a score you might need to have 2 lists and make sure that you keep the name and the corresponding score on the same row of each list.


Check out my maze game https://scratch.mit.edu/projects/144776500/

I used lists to hold x and y coordinates for my maze and also to hold the costume number of each piece of the maze.

it would be similar for making a scoreboard.
mstone326
Scratcher
1000+ posts

How to use lists in a game?

The intro project I did with my students at school using lists was for them to create an “about me” quiz. The project had 2 lists. One was called Questions and the other was called Answers.

In the questions they had to add 3 items to the list in question form.
ex:
What is my favorite food?
What is my dog's name?
What month was I born?

The Answers list held the answers in order.
pizza
Shadow
July

The main loop would repeat until the length of questions < 1 and ask item 1 of the questions. The user would answer and the if then else beneath would check for correct or incorrect. If it was incorrect we used a join block to say, good try but the answer is item 1 of answers.

Delete item 1 of questions.

That continues to loop until all the items are deleted. Was a pretty simple and fun project.Hope this helps give you an idea to give a whirl at and try using lists. One thing to remember. You should always delete all of lists you are using when you start your program then add your items back to it. In this case the lists will delete anyway but it is good practice to delete first then add.

Last edited by mstone326 (Feb. 14, 2017 01:28:12)

Pikachu1234567890123
Scratcher
6 posts

How to use lists in a game?

How do you use a list in a clicker game for the shop?
zcat22
Scratcher
1 post

How to use lists in a game?

How do you put a scratchers account name on a list?
BY147258369
Scratcher
1000+ posts

How to use lists in a game?

zcat22 wrote:

How do you put a scratchers account name on a list?
Hey there, please don't necropost. Next time, create an additional topic for your question.

In answer,

add (username) to [list v]
Andrei_ARTY
Scratcher
2 posts

How to use lists in a game?

how to make a game without sprites and only lists and variables?
BY147258369
Scratcher
1000+ posts

How to use lists in a game?

Andrei_ARTY wrote:

how to make a game without sprites and only lists and variables?
I'm not entirely sure if that's possible. Variables wouldn't be able to create some sort of player. The only type of game I could think of is a clicker game using the backdrop, but there might not be much else you could do.
unknownprints
New Scratcher
2 posts

How to use lists in a game?

what about making a sports game? Using the list as a roster viewer
Vibrato
Scratcher
1000+ posts

How to use lists in a game?

unknownprints wrote:

what about making a sports game? Using the list as a roster viewer
you could do that. But, be sure in the future to create a new topic for your question instead of necroposting
deck26
Scratcher
1000+ posts

How to use lists in a game?

Andrei_ARTY wrote:

how to make a game without sprites and only lists and variables?
All scripts would have to be in the Stage area. User interaction is by key presses or mouse clicks. But you only have backdrops to play with - no sprites means no pen blocks - so what you can do is obviously limited but it is certainly possible.

Powered by DjangoBB