/    Sign up×
Community /Pin to ProfileBookmark

Making multiple variables without defining each one

I am currently making 2d platformer game with javascript and I need to make a bunch of different blocks for the ground and all of the tiles. How can I make a bunch of variables without having to individually define each one. I don’t know much about arrays but I imagine they would be how you do this, I just can’t find anything on google on how to do this. I want to be able to control every block in the game at once to check for collisions with the player and I don’t want to make different variables for all of them.

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@SempervivumJan 02.2022 — Yes, with arrays you're on the right track. This is a good resource for javascript or client side web development in general:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach

Using a loop you can easily create a bunch of objects without defining individual variables. And later on you can use a loop either to perform the same operation on these objects.
Copy linkTweet thisAlerts:
@JerryPittengerJul 28.2022 — Thanks for the help. I have been looking for since I found variable errors in my website, this is an online casino websites platform https://casinosanalyzer.com/online-casinos/best-payout where people could check different websites for different kind of games.
Copy linkTweet thisAlerts:
@JaneNguyen1018Jul 29.2022 — Bugs on your website? Can't handle it yourself? Looking for a fix? Need HTML/CSS/Javascript/Bootstrap bugs fixed?

I will fix any kind of HTML CSS & Bootstrap & Javascript issues of your site within 1 hour.

https://www.fiverr.com/share/qeY8g2
Copy linkTweet thisAlerts:
@beatricevillAug 16.2022 — As a safety effort, Neteller will really do some cross-checking prior to moving the assets from your wallet to your Neteller club account. Neteller shows the exchange charges you're going to bring about well ahead of the exchange so that you'll understand what the installment costs in advance. At the point when you approve the exchange, Neteller sends you an affirmation email with exchange subtleties for your check and future reference. Make certain to counter-make sure that all is great since blunders in assets' beneficiary or payee data lead to Neteller energizing you to $125 for erroneous data and inversion of a mistaken exchange HERE https://casinowis.com/neteller-casinos
Copy linkTweet thisAlerts:
@clow194912Nov 03.2022 — > @JerryPittenger#1645544 Thanks for the help. I have been looking for since I found variable errors in my website, this is an online casino websites platform [https://casinosanalyzer.com/online-casinos/best-payout](https://casinosanalyzer.com/online-casinos/best-payout) where people could check different websites for different kind of games.

I don't really like casinos. You can also play other games for free. And in the treasury to lose money. I play [roms-hub.com](https://roms-hub.com/roms/nintendo-wii) . These are also free games for Nintendo, but they are just as relevant.
×

Success!

Help @grahp spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.23,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...