Game Development Reference
In-Depth Information
lq^he_bqj_pekjI]ej[=nn]uHkkl$%
w
++Ejop]jpe]pa]nn]u
[_khha_pekjF]n9jas=nn]u$%7
++=``ahaiajpopk]nn]u
[_khha_pekjF]n*lqod$bhu%7
[_khha_pekjF]n*lqod$ikomqepk%7
[_khha_pekjF]n*lqod$^aa%7
++Pn]_aajpena]nn]u_kjpajpo
bkn$r]ne6ejp9,7e8[_khha_pekjF]n*hajcpd7e''%
w
pn]_a$Ahaiajp'e'6'[_khha_pekjF]nWeY%7
y
y
y
y
This displays the following in the Output panel:
Ahaiajp,6bhu
Ahaiajp-6ikomqepk
Ahaiajp.6^aa
Searching arrays
Another interesting feature of this system is that you can create basic search functionality by throw-
ing an eb statement into the mix. It's really simple; you just check to see whether an array element in
the loop matches a certain search term. If you have a match, the element you're looking for has been
found.
Here's the basic format for searching an array:
bkn$r]ne6ejp9,7e8]nn]uJ]ia*hajcpd7e''%
w
eb$]nn]uJ]iaWeY99oa]n_dPani%
w
pn]_a$Oa]n_dpanibkqj`*%7
^na]g7
y
y
One new thing here is the keyword ^na]g, which is used to stop a loop immediately without waiting
for it to complete. When you use loops to search through arrays, you're often looking for only one
item. Once that item has been found, it doesn't make sense to continue the loop, so you can use
^na]g to stop it early. Because your program doesn't have to do any unnecessary checking, your game
will run faster.
 
Search Nedrilad ::




Custom Search