You are on page 1of 96

NEW THE SMART THINKER’S GUIDE TO C++ CODING!

 ()"&"'()%)!(

%%"()#        

#$ " !"#

&#, !
( '$)!()'( &()
$) %&('

 #$ $+$ ,%$ #$ $' ,$ $ #,#


#!$$$ ##"  "#$$ "$ #$#"$!#$
$#$ "$!   $#$ !#"$ ! #

!''(&)(&")!')  !"')#'%&)!#$)($&"'( ()!)$))(()#()$&!


#$!%) )#$")  #$( & '&%)# &)('( %"'() #$

  
  

www.pclpublications.com
঍঱ষফবশশব঻ষফবশশসন঺নযললমতষষফনই९९যত঱পসতপনত঱ধফল঺ষলপনষ
শষত঵ষনধ঺বষফবষত঱ধযনত঵঱বষশসশনশॲওস঵নতশ়ॱষলॱ঩লযযল঺ষসষল঵বতযশশফল঺
়লসফল঺ষলদ঵নতষনশলরনসষষন঵য়ন঳বদ঳঵লভনদষশ঺বষফই९९ॲ঍঩বষ৅শপতরনশ
়লস৅঵নযললমব঱প঩ল঵॰লস঵ব঱ॱধন঳ষফ঵নহবন঺শফনয঳়লস঩ব঱ধষফন
হন঵়থনশষ়লস঵রল঱ন়দত঱থস়ॲছনদলহন঵তযযষফনহন঵়থনশষ
তদ঵লশশতযযরতভল঵঳যতষ঩ল঵রশ॰শল়লস৅঵নথলস঱ধষল঩ব঱ধশলরনষফব঱প
তরতঽব঱পॲছনযদলরনষলষফন঩ত঱ষতশষবদশব঻ষফবশশসনল঩ইলধব঱পঙশন঵ॲ
ইল঱ষন঱ষশ

ॺ গত়ঌনযযলষলই९९ ॷॼ ই९९঍঱঳সষॳওসষ঳সষ


ॼ ছফ়ই९९ঃ ॸॴ ঙশন঵঍঱ষন঵তদষবল঱

ॵॴ উ঴সব঳রন঱ষ঒ননধনধ ॸॶ ইফত঵তদষন঵ঐবষন঵তযশ

ॵॶ ঌল঺ষলগনষঙ঳ই९९ব঱ছব঱ধল঺শ ॸॸ ঈন঩ব঱ব঱পইল঱শষত঱ষশ

ॵॸ ঌল঺ষলগনষঙ঳ই९९ল঱ত঑তদ ॸॺ ঊবযন঍঱঳সষॳওসষ঳সষ

ॵॺ ঌল঺ষলগনষঙ঳ই९९ব঱ঐব঱স঻
ॵॼ ওষফন঵ই९९঍ঈউশষল঍঱শষতযয ॸॼ ঐলল঳শত঱ধঈনদবশবল঱঑তমব঱প
ॹॴ ছফবযনঐলল঳

ॶॴ ই९९ঊস঱ধতরন঱ষতযশ ॹॶ ঊল঵ঐলল঳

ॶॶ ঝলস঵ঊব঵শষই९९ঔ঵লপ঵তর ॹॸ ঈলॲॲॲছফবযনঐলল঳

ॶॸ গষ঵সদষস঵নল঩তই९९ঔ঵লপ঵তর ॹॺ ঍঩গষতষনরন঱ষ

ॶॺ ইলর঳বযনত঱ধউ঻নদসষন ॹॼ ঍঩ॲॲॲউযশনগষতষনরন঱ষ

ॶॼ ঙশব঱পইলররন঱ষশ
ॷॴ চত঵বতথযনশ
ॷॶ ঈতষতঘ়঳নশ
ॷॸ গষ঵ব঱পশ
ॷॺ ই९९঑তষফশ

4 www.pclpublications.com
ইল঱ষন঱ষশ

ॹॼ ঋঅ঑উঞও঒উ
ॺॴ আবলগফলদমখনরতশষন঵নধ
ॺॶ ঐব঩নবশগষ঵ত঱পনॶ
ॺॷ ঙ঱রনরল঵়
ॺॸ গষ঵ননষএত঵ষখতদব঱প
ॺॺ ঘফনঊব঵শষঘ঵নন
ॺॻ ঍঩ঊলস঱ধॲॲॲ
ॺॼ ঘফনঙ঱঩ব঱বশফনধগ঺ত঱
ॻॴ ঊঅখॾঐল঱নগতবযশ
ॻॶ ঊললষথতযয঑ত঱তপন঵ॶॴॶॶ
ॻॷ ঔস঳঳লঽ
ॻॹ ঑ব঱নদ঵ত঩ষ
ॻॺ ঘনষ঵বশ
ॻॻ খনষ঵লআল঺যॳউ঳বদখতদনॷঈ
ॻॼ জইও঑ॶইলযযনদষবল঱
ॼॴ ঑নধবনহতয঍঍ॾঘলষতযছত঵
ॼॶ ইসষষফনখল঳নॾআঐঅগঘ
ॼॷ ঑লমলমলজ
ॼॸ অ঱লরতয়ছত঵ঽল঱নউত঵ষফ
ॼॹ অ঱লষফন঵ছল঵যধॱॶॴষফ
ॼॺ ঋ঵ত঱ধঘফন঩ষঅসষলॾইফব঱তষল঺঱ছত঵শ
ॼॻ ঈ঵তপল঱৅শঐতব঵ॷॴষফঅ঱঱বহন঵শত঵়
ॼॼ ঈবশদলউয়শবসরॱঘফনঊব঱তযইসষ
ॽॴ ঑ব঱বল঱খসশফॾখস঱঱ব঱পঋতরন
ॽॶ ঐউঋওগষত঵ছতশॾঘইগ

ॽॸ ঒ন঻ষ঍শশসন

www.pclpublications.com 5
,QGH[

6 82www.pclpublications.com
6D\+HOORWR&

C++ is a high level programming language


that’s used in a multitude of technologies.
Everything from your favourite mobile
app, console and PC game to entire
operating systems, all are developed
using C++ and a collection of software
development kits and custom libraries.
C++ is the driving force behind most
of what you use on a daily basis, which
makes it a complex and extraordinarily
powerful language to get to grips with.
In this section, we look at how to install a
C++ IDE and compiler on your computer.

 :K\&"
 (TXLSPHQW1HHGHG
 +RZWR6HW8S&LQ:LQGRZV
 +RZWR6HW8S&RQD0DF
 +RZWR6HW8S&LQ/LQX[
 2WKHU&,'(VWR,QVWDOO

www.pclpublications.com 83 7
6D\+HOORWR&

:K\&"
&LVRQHRIWKHPRVWSRSXODUSURJUDPPLQJODQJXDJHVDYDLODEOHWRGD\2ULJLQDOO\
FDOOHG&ZLWK&ODVVHVWKHODQJXDJHZDVUHQDPHG&LQ,WoVDQH[WHQVLRQRIWKH
RULJLQDO&ODQJXDJHDQGLVDJHQHUDOSXUSRVHREMHFWRULHQWHG 223 HQYLURQPHQW

C EVERYTHING
Due to how complex the language can be, and its power and performance, C++ is often used to develop games, programs,
device drivers and even entire operating systems.

'DWLQJEDFNWRWKHVWDUWRIWKHJROGHQHUDRIKRPH FRPSXWLQJODEVDQGE\UHJXODUSHRSOHZKRGLGQoWKDYHDFFHVVWRWKH
FRPSXWLQJ&RUUDWKHU&ZLWK&ODVVHVZDVWKHEUDLQFKLOGRI PDLQIUDPHVDQGODUJHFRPSXWLQJGDWDFHQWUHV
'DQLVKFRPSXWHUVFLHQWLVW%MDUQH6WURXVWUXSZKLOHZRUNLQJRQKLV
3K'WKHVLV6WURXVWUXSoVSODQZDVWRIXUWKHUWKHRULJLQDO&ODQJXDJH &oVLPSDFWLQWKHGLJLWDOZRUOGLVLPPHQVH0DQ\RIWKHSURJUDPV
ZKLFKZDVZLGHO\XVHGVLQFHWKHHDUO\VHYHQWLHV DSSOLFDWLRQVJDPHVDQGHYHQRSHUDWLQJV\VWHPVDUHFRGHGXVLQJ
&)RUH[DPSOHDOORI$GREHoVPDMRUDSSOLFDWLRQVVXFKDV
&SURYHGWREHSRSXODUDPRQJWKHGHYHORSHUVRIWKHnV 3KRWRVKRS,Q'HVLJQDQGVRRQDUHGHYHORSHGLQ&<RXZLOOƬQG
VLQFHLWZDVDPXFKHDVLHUHQYLURQPHQWWRJHWWRJULSVZLWKDQG WKDWWKHEURZVHU\RXVXUIWKH,QWHUQHWZLWKLVZULWWHQLQ&DV
PRUHLPSRUWDQWO\LWZDVFRPSDWLEOHZLWKWKHRULJLQDO& ZHOODV:LQGRZV0LFURVRIW2ƯFHDQGWKHEDFNERQHWR*RRJOHoV
ODQJXDJH7KLVPHDQWWKDWLWFRXOGEHXVHGEH\RQGWKHPDLQVWUHDP VHDUFKHQJLQH$SSOHoVPDF26LVZULWWHQODUJHO\LQ& ZLWKVRPH

C++ code is much faster than that of Python.

8 84www.pclpublications.com
:K\&"

Microsoft’s Visual Studio is a great,


free environment to learn C++ in.

RWKHUODQJXDJHVPL[HGLQGHSHQGLQJRQWKHIXQFWLRQ DQGWKHOLNHV
RI1$6$6SDFH;DQGHYHQ&(51XVH&IRUYDULRXVDSSOLFDWLRQV
SURJUDPVFRQWUROVDQGXPSWHHQRWKHUFRPSXWLQJWDVNV

&LVDOVRH[WUHPHO\HƯFLHQWDQGSHUIRUPVZHOODFURVVWKHERDUG
DVZHOODVEHLQJDQHDVL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QHHGLVWKHULJKWVHW
RIWRROVLQZKLFKWRFRPPXQLFDWHZLWKWKHFRPSXWHULQ&DQG
\RXFDQVWDUW\RXUMRXUQH\$&,'(LVIUHHRIFKDUJHHYHQWKH
LPPHQVHO\SRZHUIXO9LVXDO6WXGLRIURP0LFURVRIWLVIUHHO\DYDLODEOH
WRGRZQORDGDQGXVH<RXFDQJHWLQWR&IURPDQ\RSHUDWLQJ
V\VWHPEHLWPDF26/LQX[:LQGRZVRUHYHQPRELOHSODWIRUPV

-XVWOLNH3\WKRQWRDQVZHUWKHTXHVWLRQRI:K\&LVWKHDQVZHU
LVEHFDXVHLWoVIDVWHƯFLHQWDQGGHYHORSHGE\PRVWRIWKH
DSSOLFDWLRQV\RXUHJXODUO\XVH,WoVFXWWLQJHGJHDQGDIDQWDVWLF
ODQJXDJHWRPDVWHU

www.pclpublications.com 85 9
6D\+HOORWR&

(TXLSPHQW1HHGHG
<RXGRQoWQHHGWRLQYHVWDKXJHDPRXQWRIPRQH\LQRUGHUWROHDUQ&DQG\RX
GRQoWQHHGDQHQWLUHFRPSXWLQJODEDW\RXUGLVSRVDOHLWKHU3URYLGLQJ\RXKDYHDIDLUO\
PRGHUQFRPSXWHUHYHU\WKLQJHOVHLVIUHHO\DYDLODEOH

C++ SETUPS
Most, if not all, operating systems have C++ in their code, so it stands to reason that you can learn to program in C++ no matter
what OS you’re currently using.

COMPUTER
8QOHVV\RXIDQF\ZULWLQJRXW\RXU&FRGHE\KDQGRQDVKHHWRI
SDSHU ZKLFKLVVRPHWKLQJPDQ\ROGHUFRGHUVXVHGWRGR DFRPSXWHU
LVDQDEVROXWHPXVWKDYHFRPSRQHQW3&XVHUVFDQKDYHDQ\UHFHQW
/LQX[GLVWURRU:LQGRZV260DFXVHUVWKHODWHVWPDF26

AN IDE
-XVWDVZLWK3\WKRQDQ,'(LVXVHGWRHQWHUDQGH[HFXWH\RXU&
FRGH0DQ\,'(VFRPHZLWKH[WHQVLRQVDQGSOXJLQVWKDWKH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SHQWPDQ\\HDUVKRQLQJWKHLUFUDIWVREHSDWLHQWVWDUWVPDOODQG
NHHSOHDUQLQJ

10 86www.pclpublications.com
(TXLSPHQW1HHGHG

OS SPECIFIC NEEDS
C++ will work in any operating system but getting all the necessary pieces together can be confusing to a newcomer. Here are
VRPH26VSHFLƬFVIRU&

LINUX WINDOWS
/LQX[XVHUVDUHOXFN\LQWKDWWKH\DOUHDG\KDYHDFRPSLOHUDQG :HKDYHPHQWLRQHGSUHYLRXVO\WKDWDJRRG,'(LV0LFURVRIWoV
WH[WHGLWRUEXLOWLQWRWKHLURSHUDWLQJV\VWHP$Q\WH[WHGLWRU 9LVXDO6WXGLR+RZHYHUDEHWWHU,'(DQGFRPSLOHULV
DOORZV\RXWRW\SHRXW\RXU&FRGHZKHQLWoVVDYHGZLWKD &RGH%ORFNVZKLFKLVUHJXODUO\NHSWXSWRGDWHZLWKDQHZ
FSSH[WHQVLRQXVHJWRFRPSLOHLW UHOHDVHWZLFHD\HDU2WKHUZLVH:LQGRZVXVHUVFDQHQWHU
WKHLUFRGHLQ1RWHSDGWKHQFRPSLOHLWZLWK0LQ*:DVXVHG
E\&RGH%ORFNV

RASPBERRY PI MAC
7KH5DVSEHUU\3LoVRSHUDWLQJ 0DFRZQHUVZLOOQHHGWR
V\VWHPLV5DVSELDQZKLFK GRZQORDGDQGLQVWDOO;FRGH
LV/LQX[EDVHG7KHUHIRUH WREHDEOHWRFRPSLOHWKHLU
\RXoUHDEOHWRZULWH\RXUFRGH &FRGHQDWLYHO\2WKHU
RXWXVLQJDWH[WHGLWRUWKHQ RSWLRQVIRUWKHPDF26
FRPSLOHLWZLWKJDV\RX LQFOXGH1HWEHDQV(FOLSVHRU
ZRXOGLQDQ\RWKHU/LQX[GLVWUR &RGH%ORFNV1RWHWKH
ODWHVW&RGH%ORFNVLVQoW
DYDLODEOHIRU0DFGXHWRDODFN
RI0DFGHYHORSHUV

www.pclpublications.com 87 11
6D\+HOORWR&

+RZWR6HW8S
&LQ:LQGRZV
:LQGRZVXVHUVKDYHDZHDOWKRIFKRLFHZKHQLWFRPHVWRSURJUDPPLQJLQ&7KHUH
DUHSOHQW\RI,'(VDQGFRPSLOHUVDYDLODEOHLQFOXGLQJ9LVXDO6WXGLRIURP0LFURVRIW
+RZHYHULQRXURSLQLRQWKHEHVW&,'(WREHJLQZLWKLV&RGH%ORFNV

CODE::BLOCKS
Code::Blocks is a free C++, C and Fortran IDE that’s feature rich and easily extendible with plug-ins. It’s easy to use, comes with
a compiler and has a vibrant community behind it.

STEP 1 6WDUWE\YLVLWLQJWKH&RGH%ORFNVGRZQORDGVLWHDW STEP 3 :KHQ\RXoYHORFDWHGWKHƬOHFOLFNRQWKH


www.codeblocks.org/downloads)URPWKHUHFOLFN 6RXUFHIRUJHQHWOLQNDWWKHHQGRIWKHOLQHDQGD
RQWKHn'RZQORDGWKHELQDU\UHOHDVHVoOLQNWREHWDNHQWRWKHODWHVW GRZQORDGQRWLƬFDWLRQZLQGRZDSSHDUVFOLFNRQ6DYH)LOHWRVWDUW
GRZQORDGDEOHYHUVLRQIRU:LQGRZV WKHGRZQORDGDQGVDYHWKHH[HFXWDEOHWR\RXU3&/RFDWHWKH
GRZQORDGHG&RGH%ORFNVLQVWDOOHUDQGGRXEOHFOLFNWRVWDUW)ROORZ
WKHRQVFUHHQLQVWUXFWLRQVWREHJLQWKHLQVWDOODWLRQ

STEP 2 <RXFDQVHHWKDWWKHUHDUHVHYHUDO:LQGRZVYHUVLRQV STEP 4 2QFH\RXoYHDJUHHGWRWKHOLFHQFLQJWHUPVWKHUHLVD


DYDLODEOH7KHRQH\RXZDQWWRGRZQORDGKDV FKRLFHRILQVWDOODWLRQRSWLRQVDYDLODEOH<RXFDQRSW
nPLQJZVHWXSH[HoDWWKHHQGRIWKHFXUUHQWYHUVLRQQXPEHU$W IRUDVPDOOHULQVWDOOPLVVLQJRXWRQVRPHRIWKHFRPSRQHQWVEXWZH
WKHWLPHRIZULWLQJWKLVLVFRGHEORFNVP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&RPSLOHUDQGFOLFNWKH'HIDXOW H[DPSOHWRRXWSXWWKHZRUGVp+HOOR:RUOGqWRWKHVFUHHQLQ&
EXWWRQWRVHWLWDVWKHV\VWHPoV&FRPSLOHU&OLFN2.ZKHQ\RXoUH ZRXOGDSSHDULQELQDU\DV
UHDG\WRFRQWLQXH






STEP 7 :KHQWKHSURJUDPVWDUWVDQRWKHUPHVVDJHDSSHDUV STEP 10 7KHFRPSLOHUWKHUHIRUHWDNHVZKDW\RXoYH


LQIRUPLQJ\RXWKDW&RGH%ORFNVLVFXUUHQWO\QRWWKH HQWHUHGDV&FRGHDQGWUDQVODWHVWKDWWR
GHIDXOWDSSOLFDWLRQIRU&ƬOHV<RXDFRXSOHRIRSWLRQVWROHDYH 0DFKLQH/DQJXDJH7RH[HFXWH&FRGHWKH,'(nEXLOGVoWKHFRGH
HYHU\WKLQJDVLWLVRUDOORZ&RGH%ORFNVWRDVVRFLDWHDOO&ƬOH FKHFNLQJIRUHUURUVWKHQSDVVLWWKURXJKWKHFRPSLOHUWRFKHFN
W\SHV$JDLQZHZRXOGUHFRPPHQG\RXRSWIRUWKHODVWFKRLFHWR VWDQGDUGLVDWLRQDQGFRQYHUWLWWRRQHVDQG]HURVIRUWKHFRPSXWHU
DVVRFLDWH&RGH%ORFNVZLWKHYHU\VXSSRUWHGƬOHW\SH WRDFWXSRQ,WoVUDWKHUFOHYHUVWXƪZKHQ\RXVWRSWRWKLQNDERXWLW

www.pclpublications.com 89 13
6D\+HOORWR&

+RZWR6HW8S
&RQD0DF
7REHJLQ&FRGLQJRQD0DF\RXƬUVWQHHGWRLQVWDOO$SSOHoV;FRGH7KLVLVDIUHHIXOO
IHDWXUHG,'(WKDWoVGHVLJQHGWRFUHDWHQDWLYH$SSOHDSSV+RZHYHU\RXFDQDOVRXVHLW
WRFUHDWH&FRGHUHODWLYHO\HDVLO\

XCODE
Apple’s Xcode is primarily designed for users to develop apps for macOS, iOS, tvOS and watchOS applications in Swift or
Objective-C but you can use it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ZLQGRZ

www.pclpublications.com 91 15
6D\+HOORWR&

+RZWR6HW8S
&LQ/LQX[
/LQX[LVDJUHDW&FRGLQJHQYLURQPHQW0RVW/LQX[GLVWURVDOUHDG\KDYHWKHHVVHQWLDO
FRPSRQHQWVSUHLQVWDOOHGVXFKDVDFRPSLOHUDQGWKHWH[WHGLWRUVDUHH[FHOOHQWIRU
HQWHULQJFRGHLQWRLQFOXGLQJFRORXUFRGLQJDQGWKHUHoVWRQVRIH[WUDVRIWZDUHDYDLODEOH
WRKHOS\RXRXW

LINUX++
If you’re not familiar with Linux, then we recommend taking a look at one of our Linux titles from the BDM Publications range.
,I\RXKDYHD5DVSEHUU\3LWKHFRPPDQGVXVHGEHORZZRUNMXVWƬQHDQGIRUWKLVH[DPSOHZHoUHXVLQJ/LQX[0LQW

STEP 1 7KHƬUVWVWHSLVWRHQVXUH/LQX[LVUHDG\IRU\RXU& STEP 3 $PD]LQJO\WKDWoVLW(YHU\WKLQJLVDOUHDG\IRU\RX


FRGHVRFKHFNWKHV\VWHPDQGVRIWZDUHDUHXSWR WRVWDUWFRGLQJ+HUHoVKRZWRJHW\RXUƬUVW&
GDWH2SHQD7HUPLQDODQGHQWHUsudo apt-get update && sudo apt- SURJUDPXSDQGUXQQLQJ,Q/LQX[0LQWWKHPDLQWH[WHGLWRULV;HG
get upgrade7KHQSUHVV5HWXUQDQGHQWHU\RXUSDVVZRUG7KHVH ZKLFK\RXFDQODXQFKE\FOLFNLQJRQWKH0HQXDQGW\SLQJ;HGLQWR
FRPPDQGVXSGDWHWKHHQWLUHV\VWHPDQGDQ\LQVWDOOHGVRIWZDUH WKHVHDUFKEDU&OLFNRQWKH7H[W(GLWRUEXWWRQLQWKHULJKWKDQGSDQH
WRRSHQLW

STEP 2 0RVW/LQX[GLVWURVFRPHSUHLQVWDOOHGZLWKDOO STEP 4 ,Q;HGRUDQ\RWKHUWH[WHGLWRU\RXPD\EHXVLQJ


WKHQHFHVVDU\FRPSRQHQWVWRVWDUWFR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RQHWKDW
works best for you.

ECLIPSE (FOLSVHLVDKXJHO\SRSXODU&,'(WKDWRƪHUV CODELITE &RGH/LWHLVDIUHHDQGRSHQVRXUFH,'(WKDWoV


WKHSURJUDPPHUDZHDOWKRIIHDWXUHV,WKDVD UHJXODUO\XSGDWHGDQGDYDLODEOHIRU:LQGRZV
JUHDWFOHDQLQWHUIDFHLVHDV\WRXVHDQGDYDLODEOHIRU:LQGRZV /LQX[DQGPDF26,WoVOLJKWZHLJKWXQFRPSOLFDWHGDQGH[WUHPHO\
/LQX[DQG0DF+HDGRYHUWRwww.eclipse.org/downloads/WR SRZHUIXO<RXFDQƬQGRXWPRUHLQIRUPDWLRQDVZHOODVKRZWR
GRZQORDGWKHODWHVWYHUVLRQ,I\RXoUHVWXFNFOLFNWKH1HHG+HOSOLQN GRZQORDGDQGLQVWDOOLWDWwww.codelite.org/
IRUPRUHLQIRUPDWLRQ

GNAT 7KH*1$73URJUDPPLQJ6WXGLR *36 LVDSRZHUIXO NETBEANS $QRWKHUSRSXODUFKRLFHLV1HW%HDQV7KLV


DQGLQWXLWLYH,'(WKDWVXSSRUWVWHVWLQJGHEXJJLQJ LVDQRWKHUH[FHOOHQW,'(WKDWoVSDFNHGZLWK
DQGFRGHDQDO\VLV7KH&RPPXQLW\(GLWLRQLVIUHHZKHUHDVWKH IHDWXUHVDQGDSOHDVXUHWRXVH1HW%HDQV,'(LQFOXGHVSURMHFWEDVHG
3URYHUVLRQFRVWVKRZHYHUWKH&RPPXQLW\(GLWLRQLVDYDLODEOHIRU WHPSODWHVIRU&WKDWJLYH\RXWKHDELOLW\WREXLOGDSSOLFDWLRQVZLWK
:LQGRZV0DF/LQX[DQGHYHQWKH5DVSEHUU\3L<RXFDQƬQGLWDW G\QDPLFDQGVWDWLFOLEUDULHV)LQGRXWPRUHDWwww.netbeans.org/
www.adacore.com/download features/cpp/index.html.

18 94www.pclpublications.com
2WKHU&,'(VWR,QVWDOO

VISUAL STUDIO 0LFURVRIWoV9LVXD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U++ 8OWLPDWHLVDFURVVSODWIRUP&,'(WKDWERDWVDUDSLG


LVDQROGHU,'(WKDWLVIRU:LQGRZVV\VWHPVRQO\ GHYHORSPHQWRIFRGHWKURXJKWKHVPDUWDQGDJJUHVVLYH
+RZHYHUPDQ\XVHUVSUDLVHLWVFOHDQLQWHUIDFHDQGXQFRPSOLFDWHG XVHRI&)RUWKHQRYLFHLWoVDEHDVWRIDQ,'(EXWEHKLQGLWV
ZD\RIFRGLQJDQGFRPSLOLQJ$OWKRXJKWKHUHoVQRWEHHQPXFK FRPSOH[LW\LVDEHDXW\WKDWZRXOGPDNHDGHYHORSHUoVNQHHVJR
XSGDWLQJIRUVRPHWLPHLWoVFHUWDLQO\RQHWRFRQVLGHULI\RXZDQW ZREEO\)LQGRXWPRUHDWwww.ultimatepp.org/index.html
VRPHWKLQJGLƪHUHQWwww.bloodshed.net/devcpp.html

www.pclpublications.com 95 19
,QGH[

20 96www.pclpublications.com
&)XQGDPHQWDOV

Within this section you can begin to


understand the structure of C++ code
and how to compile and execute that
code. These are the fundamentals of C++,
which teach you the basics such as using
comments, variables, data types, strings
and how to use C++ mathematics.
These are the building blocks of a C++
program. With them, you can form your
own code, produce an output to the
screen and store and retrieve data.

 <RXU)LUVW&3URJUDP
 6WUXFWXUHRID&3URJUDP
 &RPSLOHDQG([HFXWH
 8VLQJ&RPPHQWV
 9DULDEOHV
 'DWD7\SHV
 6WULQJV
 &0DWKV

www.pclpublications.com 97 21
&)XQGDPHQWDOV

<RXU)LUVW&3URJUDP
<RXPD\KDYHIROORZHGWKH0DFDQG/LQX[H[DPSOHVSUHYLRXVO\EXW\RXoUHJRLQJWREH
ZRUNLQJH[FOXVLYHO\LQ:LQGRZVDQG&RGH%ORFNVIURPKHUHRQ/HWoVEHJLQE\ZULWLQJ
\RXUƬUVW&SURJUDPDQGWDNLQJWKHƬUVWVPDOOVWHSLQWRDODUJHUFRGLQJZRUOG

HELLO, WORLD!
,WoVWUDGLWLRQDOLQSURJUDPP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UDPLVVWUXFWXUHGƬUVWWKHQ\RXFDQEXLOG
1RZHQWHU DQGUXQWKHFRGH)RUQRZFOLFNRQ6DYHWKHVLQJOHƮRSS\GLVFLFRQ
0\ÀUVW&SURJUDP

www.pclpublications.com 99 23
&)XQGDPHQWDOV

6WUXFWXUHRID
&3URJUDP
&KDVDYHU\GHƬQHGVWUXFWXUHDQGZD\RIGRLQJWKLQJV0LVVVRPHWKLQJRXWHYHQ
DVVPDOODVDVHPLFRORQDQG\RXUHQWLUHSURJUDPZLOOIDLOWREHFRPSLOHGDQGH[HFXWHG
0DQ\DSURIHVVLRQDOSURJUDPPHUKDVIDOOHQIRXORIVORSS\VWUXFWXUH

#INCLUDE <C++ STRUCTURE>


/HDUQLQJWKHEDVLFVRISURJUDPPLQJ\RXEHJLQWRXQGHUVWDQGWKHVWUXFWXUHRIDSURJUDP7KHFRPPDQGVPD\EHGLƪHUHQW
from one language to the next, but you will start to see how the code works.

C++ #INCLUDE
7KHVWUXFWXUHRID&SURJUDP
&ZDVLQYHQWHGE\'DQLVK LVTXLWHSUHFLVH(YHU\&FRGH
VWXGHQW%MDUQH6WURXVWUXSLQ EHJLQVZLWKDGLUHFWLYH#include
DVDSDUWRIKLV3K' <>7KHGLUHFWLYHLQVWUXFWVWKH
WKHVLV,QLWLDOO\&ZDVFDOOHG& SUHSURFHVVRUWRLQFOXGHD
ZLWK&ODVVHVZKLFKDGGHG VHFWLRQRIWKHVWDQGDUG&
IHDWXUHVWRWKHDOUHDG\SRSXODU FRGH)RUH[DPSOH#include
&SURJUDPPLQJODQJXDJH <iostream>LQFOXGHVWKH
ZKLOHPDNLQJLWDPRUH LRVWUHDPKHDGHUWRVXSSRUW
XVHUIULHQGO\HQYLURQPHQW LQSXWRXWSXWRSHUDWLRQV
WKURXJKDQHZVWUXFWXUH

Bjarne Stroustrup, inventor


of C++.
,170$,1Ǔǔ
int main()LQLWLDWHVWKH
GHFODUDWLRQRIDIXQFWLRQZKLFK
LVDJURXSRIFRGH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FRGHDVPHQWLRQHGSUHYLRXVO\ EUDFHWRLQGLFDWHWKHHQGRIWKHPDLQIXQFWLRQ

www.pclpublications.com 10125
&)XQGDPHQWDOV

&RPSLOHDQG([HFXWH
<RXoYHFUHDWHG\RXUƬUVW&SURJUDPDQG\RXQRZXQGHUVWDQGWKHEDVLFVEHKLQGWKH
VWUXFWXUHRIRQH/HWoVDFWXDOO\JHWWKLQJVPRYLQJDQGFRPSLOHDQGH[HFXWHRUUXQLI
\RXSUHIHUWKHSURJUDPDQGVHHKRZLWORRNV

GREETINGS FROM C++


Compiling and executing C++ code from Code::Blocks is extraordinarily easy; just a matter of clicking an icon and seeing the
result. Here’s how it’s done.

STEP 1 2SHQ&RGH%ORFNVLI\RXKDYHQoWDOUHDG\DQG STEP 3 6WDUWE\FOLFNLQJRQWKH%XLOGLFRQWKH\HOORZFRJ


ORDGXSWKHSUHYLRXVO\VDYHG+HOOR:RUOGFRGH\RX $WWKLVSRLQW\RXUFRGHKDVQRZEHHQUXQWKURXJK
FUHDWHG(QVXUHWKDWWKHUHDUHQRYLVLEOHHUURUVVXFKDVPLVVLQJ WKH&RGH%ORFNVFRPSLOHUDQGFKHFNHGIRUDQ\HUURUV<RXFDQVHH
VHPLFRORQVDWWKHHQGRIWKHVWGFRXWOLQH WKHUHVXOWVRIWKH%XLOGE\ORRNLQJWRWKHERWWRPZLQGRZSDQH$Q\
PHVVDJHVUHJDUGLQJWKHTXDOLW\RIWKHFRGHDUHGLVSOD\HGKHUH

STEP 2 ,I\RXUFRGHLVORRNLQJVLPLODUWRWKHRQHLQRXU STEP 4 1RZFOLFNRQWKH5XQLFRQWKHJUHHQSOD\EXWWRQ


VFUHHQVKRWWKHQORRNWRWKHPHQXEDUDORQJWKHWRS $FRPPDQGOLQHER[DSSHDUVRQ\RXUVFUHHQ
RIWKHVFUHHQ8QGHUWKH)RUWUDQHQWU\LQWKHWRSPRVWPHQX\RXFDQ GLVSOD\LQJWKHZRUGV+HOORZRUOGIROORZHGE\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QWKHVKRHVRIVRPHRQHZKRVHMRELWLVWRƬQGRXW
ZKDWoVZURQJZLWKDSURJUDP7KHSURJUDP
KDVLQH[FHVVRIOLQHVRIFRGH
VSUHDGDFURVVVHYHUDOGLƪHUHQW
PRGXOHV<RXFDQVRRQDSSUHFLDWH
WKHQHHGIRUDOLWWOHKHOSIURPWKH
RULJLQDOSURJUDPPHUVLQWKHIRUPRID
JRRGFRPPHQW

7KHEHVWFRPPHQWVDUHDOZD\VFRQFLVH
DQGOLQNWKHFRGHORJLFDOO\GHWDLOLQJZKDW
KDSSHQVZKHQWKH
SURJUDPKLWVWKLV
OLQHRUVHFWLRQ
<RXGRQoWQHHG
WRFRPPHQW
RQHYHU\OLQH
6RPHWKLQJDORQJ
WKHOLQHVRILI
[ GRHVQoW
UHTXLUH\RXWR
FRPPHQWWKDWLI[
HTXDOV]HURWKHQ
GRVRPHWKLQJ

28104www.pclpublications.com
8VLQJ&RPPHQWV

C++ COMMENTS
Commenting in C++ involves using a double forward slash ‘/’, or a forward slash and an asterisk, ‘/*’. You’ve already seen some
brief examples but this is how they work.

STEP 1 8VLQJWKH+HOOR:RUOGFRGHDVDQH[DPSOH\RXFDQ STEP 4 %HFDUHIXOZKHQFRPPHQWLQJHVSHFLDOO\ZLWKEORFN


HDVLO\FRPPHQWRQGLƪHUHQWVHFWLRQVRIWKHFRGH FRPPHQWV,WoVYHU\HDV\WRIRUJHWWRDGGWKHFORVLQJ
XVLQJWKHGRXEOHIRUZDUGVODVK DVWHULVNDQGIRUZDUGVODVKDQGWKXVQHJDWHDQ\FRGHWKDWIDOOVLQVLGH
WKHFRPPHQWEORFN
0\ÀUVW&SURJUDP
FRXW´+HOORZRUOG?Qµ

STEP 2 +RZHYHU\RXFDQDOVRDGGFRPPHQWVWRWKHHQG STEP 5 2EYLRXVO\LI\RXWU\DQGEXLOGDQGH[HFXWHWKH


RIDOLQHRIFRGHWRGHVFULEHLQDEHWWHUZD\ZKDWoV FRGHLWHUURUVRXWFRPSOD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HIRUHLWFDQEHXVHG

THE DECLARATION OF VARIABLES


You can declare a C++ variable by using statements within the code. There are several distinct types of variables you can
declare. Here’s how it works.

STEP 1 2SHQXSDQHZEODQN&ƬOHDQGHQWHUWKHXVXDO STEP 3 <RXFDQEXLOGDQGUXQWKHFRGHEXWLWZRQoWGR


FRGHKHDGHUV PXFKRWKHUWKDQVWRUHWKHYDOXHVDQGWRWKH
LQWHJHUVDDQGE7RRXWSXWWKHFRQWHQWVRIWKHYDULDEOHVDGG
LQFOXGHLRVWUHDP!
XVLQJQDPHVSDFHVWG FRXWD
FRXWµ?Qµ
LQWPDLQ
FRXWE
^
7KHFRXWp?QqSDUW
`
VLPSO\SODFHVDQHZOLQH
EHWZHHQWKHRXWSXWRI
DQG

STEP 2 6WDUWVLPSOHE\FUHDWLQJWZRYDULDEOHVDDQGEZLWK STEP 4 1DWXUDOO\\RXFDQGHFODUHDQHZYDULDEOHFDOOLW


RQHKDYLQJDYDOXHRIDQGWKHRWKHU<RXFDQ UHVXOWDQGRXWSXWVRPHVLPSOHDULWKPHWLF
XVHWKHGDWDW\SHLQWWRGHFODUHWKHVHYDULDEOHV:LWKLQWKHFXUO\
LQWUHVXOW
EUDFNHWVHQWHU
UHVXOW DE
LQWD
FRXWUHVXOW
LQWE
,QVHUWWKHDERYHLQWRWKHFRGHDVSHUWKHVFUHHQVKRW
D 
E 

106www.pclpublications.com
30
9DULDEOHV

STEP 5 <RXFDQDVVLJQDYDOXHWRDYDULDEOHDVVRRQDV\RX STEP 8 7KHSUHYLRXVVWHSFUHDWHVWKHYDULDEOH6WDUW/LYHV


GHFODUHLW7KHFRGH\RXoYHW\SHGLQFRXOGORRNOLNH ZKLFKLVDJOREDOYDULDEOH,QDJDPHIRUH[DPSOH
WKLVLQVWHDG DSOD\HUoVOLYHVJRXSRUGRZQGHSHQGLQJRQKRZZHOORUKRZEDG
WKH\oUHGRLQJ:KHQWKHSOD\HUUHVWDUWVWKHJDPHWKH6WDUW/LYHV
LQWD 
U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7DNHDORRNDWWKHVFUHHQVKRWWRVHH
VWULQJJUHHW JUHHWJUHHW
WKHUHVXOWRIWKHFRGH
FRXWJUHHW´?Qµ
`

www.pclpublications.com 11135
&)XQGDPHQWDOV

&0DWKV
3URJUDPPLQJLVPDWKHPDWLFDOLQQDWXUHDQGDV\RXPLJKWH[SHFWWKHUHoVSOHQW\RI
EXLOWLQVFRSHIRUVRPHTXLWHLQWHQVHPDWKV&KDVDORWWRRƪHUVRPHRQHZKRoV
LPSOHPHQWLQJPDWKHPDWLFDOPRGHOVLQWRWKHLUFRGH,WFDQEHH[WUHPHO\FRPSOH[RU
UHODWLYHO\VLPSOH

C++ = MC2
The basic mathematical symbols apply in C++ as they do in most other programming languages. However, by using the C++
Math Library, you can also calculate square roots, powers, trig and more.

STEP 1 &oVPDWKHPDWLFDORSHUDWLRQVIROORZWKH STEP 3 0XOWLSOLFDWLRQDQGGLYLVLRQFDQEHDSSOLHGDVVXFK


VDPHSDWWHUQVDVWKRVHWDXJKWLQVFKRROLQWKDW
LQFOXGHLRVWUHDP!
PXOWLSOLFDWLRQDQGGLYLVLRQWDNHSUHFHGHQFHRYHUDGGLWLRQDQG
XVLQJQDPHVSDFHVWG
VXEWUDFWLRQ<RXFDQDOWHUWKDWWKRXJK)RUQRZFUHDWHDQHZƬOH
DQGHQWHU LQWPDLQ
^
LQFOXGHLRVWUHDP!
ÁRDWQXPEHUV 
XVLQJQDPHVSDFHVWG
QXPEHUV QXPEHUV 7KLVPXOWLSOLHV
LQWPDLQ
E\
^
ÁRDWQXPEHUV  FRXWQXPEHUV´?Qµ
QXPEHUV QXPEHUV7KLVDGGVWRWKH QXPEHUV QXPEHUV$QGWKLVGLYLGHV
LQLWLDO E\
FRXWQXPEHUV´?Qµ FRXWQXPEHUV´?Qµ
QXPEHUV QXPEHUV7KLVVXEWUDFWV `
IURPWKHQHZ
FRXWQXPEHUV´?Qµ
`

STEP 2 :KLOHVLPSOHLWGRHVJHWWKHROGPDWKVPXVFOH
Z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RDWFDOOHGQXPEHUZLWKWKH


YDOXHRIDQGWKHSRZ YDULDEOHSRZHU LVZKHUH
WKHFDOFXODWLRQKDSSHQV2IFRXUVH\RXFDQFDOFXODWHSRZHUVDQG
LQFOXGHLRVWUHDP!
VTXDUHURRWVZLWKRXWXVLQJYDULDEOHV)RUH[DPSOHSRZ  
LQFOXGHFPDWK!
RXWSXWVWKHVDPHYDOXHDVWKHƬUVWFRXWOLQHLQWKHFRGH
XVLQJQDPHVSDFHVWG
LQWPDLQ
^
ÁRDWQXPEHU 
FRXW´7KHVTXDUHURRWRI´QXPEHU´
LV´VTUW QXPEHU ´?Qµ
`

STEP 10 7KHYDOXHRI3LLVDOVRVWRUHGLQWKHFPDWKKHDGHU
OLEUDU\,WFDQEHFDOOHGXSZLWKWKH0B3,IXQFWLRQ
(QWHUFRXW0B3,LQWRWKHFRGHDQG\RXJHWRU\RXFDQ
XVHLWWRFDOFXODWH
LQFOXGHLRVWUHDP!
LQFOXGHFPDWK!
XVLQJQDPHVSDFHVWG
LQWPDLQ
^
GRXEOHDUHDUDGLXV 
DUHD 0B3, UDGLXV UDGLXV
STEP 7 +HUHZHFUHDWHGDQHZƮRDWFDOOHGQXPEHUDQG
XVHGWKHVTUW QXPEHU IXQFWLRQWRGLVSOD\WKH FRXWDUHD´?Qµ
VTXDUHURRWRIWKHYDOXHRIWKHYDULDEOHQXPEHU%XLOGDQGUXQ
`
WKHFRGHDQG\RXUDQVZHUUHDGV

www.pclpublications.com 11337
,QGH[

38114www.pclpublications.com
&,QSXW2XWSXW

There’s a satisfying feeling when you


program code that asks the user for
input, then uses that input to produce
something that the user can see. Even if
it’s simply asking for someone’s name,
and displaying a personal welcome
message, it’s a big leap forward.
User interaction, character literals,
GHƬQLQJFRQVWDQWVDQGƬOHLQSXWDQG
output are all covered in the following
pages. All of which help you to understand
how a C++ program works better.

 8VHU,QWHUDFWLRQ
 &KDUDFWHU/LWHUDOV
 'HƬQLQJ&RQVWDQWV
 )LOH,QSXW2XWSXW

www.pclpublications.com 11539
&,QSXW2XWSXW

8VHU,QWHUDFWLRQ
7KHUHoVQRWKLQJTXLWHDVVDWLVI\LQJDVFUHDWLQJDSURJUDPWKDWUHVSRQGVWR\RX7KLV
EDVLFXVHULQWHUDFWLRQLVRQHRIWKHPRVWWDXJKWDVSHFWVRIDQ\ODQJXDJHDQGZLWKLW
\RXoUHDEOHWRGRPXFKPRUHWKDQVLPSO\JUHHWWKHXVHUE\QDPH

HELLO, DAVE
You have already used cout, the standard output stream, throughout our code. Now you’re going to be using cin, the standard
input stream, to prompt a user response.

STEP 1 $Q\WKLQJWKDW\RXZDQWWKHXVHUWRLQSXWLQWRWKH STEP 3 7KHFLQFRPPDQGZRUNVLQWKHRSSRVLWHZD\IURP


SURJUDPQHHGVWREHVWRUHGVRPHZKHUHLQWKH WKHFRXWFRPPDQG:LWKWKHƬUVWFRXWOLQH\RXoUH
V\VWHPPHPRU\VRLWFDQEHUHWULHYHGDQGXVHG7KHUHIRUHDQ\ RXWSXWWLQJn:KDWLV\RXUDJHoWRWKHVFUHHQDVLQGLFDWHGZLWKWKH
LQSXWPXVWƬUVWEHGHFODUHGDVDYDULDEOHVRLWoVUHDG\WREHXVHGE\ FKHYURQV&LQXVHVRSSRVLWHIDFLQJFKHYURQVLQGLFDWLQJDQLQSXW7KH
WKHXVHU6WDUWE\FUHDWLQJDEODQN&ƬOHZLWKKHDGHUV LQSXWLVSXWLQWRWKHLQWHJHUDJHDQGFDOOHGXSLQWKHVHFRQGFRXW
FRPPDQG%XLOGDQGUXQWKHFRGH

STEP 4 ,I\RXoUHDVNLQJDTXHVWLRQ\RXQHHGWRVWRUHWKH
LQSXWDVDVWULQJWRDVNWKHXVHUWKHLUQDPH\RX
ZRXOGXVH
LQFOXGHLRVWUHDP!
STEP 2 7KHGDWDW\SHRIWKHYDULDEOHPXVWDOVRPDWFKWKH XVLQJQDPHVSDFHVWG
W\SHRILQSXW\RXZDQWIURPWKHXVHU)RUH[DPSOH
LQWPD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OHWKDWRQFHGHƬQHGUHPDLQVWKHVDPHWKURXJKRXW
WKHFRGH+RZHYHUDFKDUDFWHUOLWHUDOLVGHƬQHGE\DEDFNVODVKVXFKDVWKH?Q\RXoYH
EHHQXVLQJDWWKHHQGRIDFRXWVWDWHPHQWWRVLJQLI\DQHZOLQH

ESCAPE SEQUENCE
When used in something like a cout statement, character literals are also called Escape Sequence Codes. They allow you to
insert a quote, an alert, new line and much more.

STEP 1 &UHDWHDQHZ&ƬOHDQGHQWHUWKHUHOHYDQWKHDGHUV STEP 3 ,I\RXZDQWHGWRLQVHUWVSHHFKTXRWHVLQVLGHDFRXW


VWDWHPHQW\RXZRXOGKDYHWRXVHDEDFNVODVKDVLW
LQFOXGHLRVWUHDP! DOUHDG\XVHVTXRWHV
XVLQJQDPHVSDFHVWG
LQFOXGHLRVWUHDP!
LQWPDLQ XVLQJQDPHVSDFHVWG
^
LQWPDLQ
^
` FRXW´+HOORXVHU7KLVLVKRZWRXVH
?µTXRWHV?µµ
`

STEP 2 <RXoYHDOUHDG\H[SHULHQFHGWKH?QFKDUDFWHUOLWHUDO STEP 4 7KHUHoVHYHQDFKDUDFWHUOLWHUDOWKDWFDQWULJJHUDQ


SODFLQJDQHZOLQHZKHUHYHULWoVFDOOHG7KHOLQHcout DODUP,Q:LQGRZVLWoVWKHQRWLƬFDWLRQVRXQG
<< “Hello\n” << “I’m a C++\n” << “Program\n”; RXWSXWVWKUHHOLQHV WKDWFKLPHVZKHQ\RXXVH?D7U\WKLVFRGHDQGWXUQXS\RXUVRXQG
RIWH[WHDFKVWDUWLQJDIWHUWKHODVW?Q
LQFOXGHLRVWUHDP!
XVLQJQDPHVSDFHVWG
LQWPDLQ
^
FRXW´$/$50?Dµ
`

42118www.pclpublications.com
&KDUDFWHU/LWHUDOV

A HANDY CHART
There are numerous character literals, or escape sequence codes, to choose from. We therefore thought it would be good for
you to have a handy chart available, for those times when you need to insert a code.

ESCAPE SEQUENCE CODE CHARACTER


\\ Backslash

\’ Single Quote

\” Double Quote (Speech Marks)

\? Question Mark

\a Alert/Alarm

\b Backspace

\f Form Feed

\n New Line

\r Carriage Return

\t Horizontal Tab

\v Vertical Tab

\0 Null Character

\uxxxx Unicode (UTF-8)

\Uxxxxxxxx Unicode (UTF-16)

81,&2'(&+$5$&7(56Ǔ87)Ǖǔ
8QLFRGHFKDUDFWHUVDUHV\PEROVRUFKDUDFWHUVWKDWDUHVWDQGDUGDFURVV
DOOSODWIRUPV)RUH[DPSOHWKHFRS\ULJKWV\PEROWKDWFDQEHHQWHUHG
YLDWKHNH\ERDUGE\HQWHULQJWKH8QLFRGHFRGHIROORZHGE\$/7;,Q
WKHFDVHRIWKHFRS\ULJKWV\PEROHQWHU$$OW;,Q&FRGH\RX
ZRXOGHQWHU
LQFOXGHLRVWUHDP!
XVLQJQDPHVSDFHVWG
LQWPDLQ
^
FRXW´?X$µ

UNICODE
CHARACTER TABLE
$FRPSOHWHOLVWRIWKHDYDLODEOH8QLFRGH
FKDUDFWHUVFDQEHIRXQGDWwww.
unicode-table.com/en/+RYHU\RXU
PRXVHRYHUWKHFKDUDFWHUWRVHHLWV
XQLTXHFRGHWRHQWHULQ&

www.pclpublications.com 11943
&,QSXW2XWSXW

'HƬQLQJ&RQVWDQWV
&RQVWDQWVDUHƬ[HGYDOXHVLQ\RXUFRGH7KH\FDQEHDQ\EDVLFGDWDW\SHEXWDVWKH
QDPHVXJJHVWVWKHLUYDOXHUHPDLQVFRQVWDQWWKURXJKRXWWKHHQWLUHFRGH7KHUHDUHWZR
VHSDUDWHZD\VWRGHƬQHDFRQVWDQWLQ&WKHGHƬQHSUHSURFHVVRUDQGFRQVW

#DEFINE
The pre-processors are instructions to the compiler to pre-process the information before it goes ahead and compiles the
FRGHLQFOXGHLVDSUHSURFHVVRUDVLVGHƬQH

STEP 1 <RXFDQXVHWKHGHƬQHSUHSURFHVVRUWRGHƬQHDQ\ STEP 3 1RWHWKHFDSLWDOVIRUGHƬQHGFRQVWDQWVLWoV


FRQ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DPHDJHSKRQHQXPEHUHWF0D\EHHYHQWKH
WKHVDPHIROGHUZKHUHWKHFRGHZDVORFDWHGWKLVLVGRQHE\GHIDXOW YDOXHRI3LDQGYDULRXVPDWKHPDWLFDOHOHPHQWV,WoVDOOJRRGSUDFWLFH
7RVSHFLI\DQRWKHUIROGHU\RXQHHGWRXVHGRXEOHEDFNVODVKHVDV
SHUWKHFKDUDFWHUOLWHUDOVHVFDSHVHTXHQFHFRGH

www.pclpublications.com 12347
,QGH[

/RRSVDQG
'HFLVLRQ0DNLQJ

124www.pclpublications.com
48
Loops and Decision Making

Loops and repetition are one of the most


important factors of any programming
language. Good use of a loop creates a
program that does exactly what you want
it to and delivers the desired outcome
without issues or errors.
Without loops and decision making
events within the code, your program will
QHYHUEHDEOHWRRƪHUWKHXVHUDQ\FKRLFH
It’s this understanding of choice that
elevates your skills as a programmer and
makes for much better code.

 :KLOH/RRS
 )RU/RRS
 'Rf:KLOH/RRS
 ,I6WDWHPHQW
 ,If(OVH6WDWHPHQW

www.pclpublications.com 12549
Loops and Decision Making

:KLOH/RRS
$ZKLOHORRSoVIXQFWLRQLVWRUHSHDWDVWDWHPHQWRUDJURXSRIVWDWHPHQWVZKLOHDFHUWDLQ
FRQGLWLRQUHPDLQVWUXH:KHQWKHZKLOHORRSVWDUWVLWLQLWLDOLVHVLWVHOIE\WHVWLQJWKH
FRQGLWLRQRIWKHORRSDQGWKHVWDWHPHQWVZLWKLQEHIRUHH[HFXWLQJWKHUHVWRIWKHORRS

TRUE OR FALSE?
While loops are one of the most popular form of C++ code looping. They repeatedly run the code contained within the loop
while the condition is true. Once it proves false, the code continues as normal.

STEP 1 &OHDUZKDW\RXoYHGRQHVRIDUDQGFUHDWHDQHZ& STEP 3 )LUVW\RX


ƬOH7KHUHoVQRQHHGIRUDQ\H[WUDKHDGHUVDWWKH QHHGWR
PRPHQWVRDGGWKHVWDQGDUGKHDGHUVDVSHUXVXDO FUHDWHDFRQGLWLRQVRXVHD
YDULDEOHFD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QJZLWKWKHKHDGHULWQHHGV 
\RXZRXOGHQWHU DQGDZKLOHORRSHQDEOHV\RXWRFRPHXSZLWKVRPHLQWHUHVWLQJ
FRXQWGRZQFRGH
LQFOXGHLRVWUHDP!
LQFOXGHIVWUHDP! LQFOXGHLRVWUHDP!
XVLQJQDPHVSDFHVWG LQFOXGHZLQGRZVK!
XVLQJQDPHVSDFHVWG
LQWPDLQ
LQWPDLQ
^
VWULQJZRUG ^
LIVWUHDPQHZÀOH ´&??XVHUV??GDYLG?? LQWD 
'RFXPHQWV??&LPPHULDW[Wµ 
ZKLOH D 
FRXW´&LPPHULDE\5REHUW(+RZDUG?Qµ ^
HQGO FRXWDHQGO
D D
ZKLOH QHZÀOH!!ZRUG
6OHHS  
^
`
FRXWZRUGHQGO
` FRXW´?Q%ODVW2IIµHQGO
UHWXUQ UHWXUQ
` `

www.pclpublications.com 12751
Loops and Decision Making

)RU/RRS
,QVRPHUHVSHFWVDIRUORRSZRUNVLQDYHU\VLPLODUZD\WRWKDWRIDZKLOHORRSDOWKRXJKLWoV
VWUXFWXUHLVGLƪHUHQW$IRUORRSLVVSOLWLQWRWKUHHVWDJHVDQLQLWLDOLVHUDFRQGLWLRQDQGDQ
LQFUHPHQWDOVWHS2QFHVHWXSWKHORRSUHSHDWVLWVHOIXQWLOWKHFRQGLWLRQEHFRPHVIDOVH

LOOPY LOOPS
The initialise stage of a for loop is executed only once and this sets the point reference for the loop. The condition is evaluated
by the loop to see if it’s true or false and then the increment is executed. The loop then repeats the second and third stage.

STEP 1 &UHDWHDQHZ&ƬOHZLWKWKHVWDQGDUGKHDGHUV STEP 4 $IWHUWKHORRS\RXFUHDWHGDFRPSRXQGVWDWHPHQW


LQEUDFHV FXUO\EUDFNHWV WKDWGLVSOD\VWKHFXUUHQW
LQFOXGHLRVWUHDP! YDOXHRIWKHLQWHJHUQXP(YHU\WLPHWKHIRUORRSUHSHDWVLWVHOIWKH
XVLQJQDPHVSDFHVWG VHFRQGDQGWKLUGVWD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WHRIWKHFRQGLWLRQDWWKHVWDUWRIWKHORRSRUWKHWRSRI
WKHORRSLI\RXSUHIHU+RZHYHUDGRfZKLOHORRSLVVLPLODUWRDZKLOHORRSEXWLQVWHDG
FKHFNVWKHFRQGLWLRQDWWKHERWWRPRIWKHORRS

DO LOOPS
The good thing about a do… while loop is that it’s guaranteed to run through at least once. It’s structure is: do, followed by
statements, while condition is true. This is how it works.

STEP 1 %HJLQZLWKDQHZEODQN&ƬOHDQGHQWHUWKH STEP 3 1RZKHUHoVDORRNDWWKHVWUXFWXUHRIDGRfZKLOH


VWDQGDUGKHDGHUV ORRS)LUVW\RXFUHDWHDQLQWHJHUFDOOHGQXPZLWK
WKHYDOXHRI1RZWKHGRfZKLOHORRSVEHJLQV7KHFRGHLQVLGH
LQFOXGHLRVWUHDP!
WKHERG\RIWKHORRSLVH[HFXWHGDWOHDVWRQFHWKHQWKHFRQGLWLRQLV
XVLQJQDPHVSDFHVWG
FKHFNHGIRUHLWKHUWUXHRUIDOVH
LQWPDLQ
^

STEP 2 %HJLQZLWKDVLPSOHQXPEHUFRXQW

^
LQWQXP  STEP 4 ,IWKHFRQGLWLRQLVWUXHWKHORRSLVH[HFXWHG7KLV
FRQWLQXHVXQWLOWKHFRQGLWLRQLVIDOVH:KHQWKH
GR FRQGLWLRQKDVEHHQH[SUHVVHGDVIDOVHWKHORRSWHUPLQDWHVDQGWKH
^ FRGHFRQWLQXHV7KLVPHDQV\RXFDQFUHDWHDORRSZKHUHWKHFRGH
FRXW´1XPEHU´QXPHQGO FRQWLQXHVXQWLOWKHXVHUHQWHUVDFHUWDLQFKDUDFWHU
QXP QXP
`
ZKLOH QXP 
UHWXUQ
`

130www.pclpublications.com
54
'Rf:KLOH/RRS

STEP 5 ,I\RXZDQWFRGHWRDGGXSXVHULQSXWWHGQXPEHUV STEP 8 )LQDOO\WKHZKLOHVWDWHPHQWFKHFNVWKHFRQGLWLRQ


XQWLOWKHXVHUHQWHUV]HUR RIWKHYDULDEOHQX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OHDVWRQFH IRUH[DPSOHWRFKHFN
YDULDEOHQXPEHU7KHFDOFXODWLRQVWHSXVHVWKHVHFRQGƮRDWLQJ
WKHQXPEHURIOLYHVLQDJDPH WKHQDGRfZKLOHORRSLVSHUIHFW
SRLQWYDULDEOHVXPZKLFKDGGVWKHYDOXHRIQXPEHUHYHU\WLPHWKH
XVHUHQWHUVDQHZYDOXH

www.pclpublications.com 13155
Loops and Decision Making

,I6WDWHPHQW
7KHGHFLVLRQPDNLQJVWDWHPHQWnLIoLVSUREDEO\RQHRIWKHPRVWXVHGVWDWHPHQWVLQDQ\
SURJUDPPLQJODQJXDJHUHJDUGOHVVRIZKHWKHULWoV&3\WKRQ%$6,&RUDQ\WKLQJ
HOVH,WUHSUHVHQWVDMXQFWLRQLQWKHFRGHZKHUH,)RQHFRQGLWLRQLVWUXHGRWKLVRU,)LWoV
IDOVHGRWKDW

IF ONLY
If uses a Boolean expression within its statement. If the Boolean expression is true, the code within the statement is executed.
If not, then the code after the statement is executed instead.

STEP 1 )LUVWFUHDWHDQHZ&ƬOHDQGHQWHUWKHUHOHYDQW
VWDQGDUGKHDGHUVDVXVXDO
LQFOXGHLRVWUHDP!
XVLQJQDPHVSDFHVWG
LQWPDLQ
^

STEP 2 ,ILVEHVWH[SODLQHGZKHQ\RXXVHDQXPEHU STEP 3 :KDWoVJRLQJRQKHUH"7REHJLQDQLQWHJHUFDOOHG


EDVHGFRQGLWLRQ QXPZDVFUHDWHGDQGDVVLJQHGZLWKWKHYDOXHRI
7KHLIVWDWHPHQWFRPHVQH[WDQGLQWKLVFDVHZHoYHLQVWUXFWHGWKH
^
FRGHWKDWLIWKHFRQGLWLRQWKHYDOXHRIQXPLVOHVVWKDQWKHQWKH
LQWQXP 
FRGHZLWKLQWKHEUDFHVVKRXOGEHH[HFXWHG
LI QXP
^
FRXW´7KHQXPEHULVOHVVWKDQµ
HQGO
`
FRXW´9DOXHRIQXPEHULV´QXPHQGO
STEP 4 7KHVHFRQGFRXWVWDW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WLFYDOXH
` WKHGRfZKLOHORRSLVWHUPLQDWHGDQGDIULHQGO\n*RRGE\HoLV
LI WHPS! GLVSOD\HGWRWKHVFUHHQ
^
FRXW´?Q$WOHDVWLW·VQRW
IUHH]LQJµHQGO
`
`
ZKLOH WHPS  
FRXW´?Q*RRGE\H?QµHQGO
UHWXUQ
`

STEP 10 8VLQJLILVTXLWHSRZHUIXOLILWoVXVHGFRUUHFWO\-XVW
UHPHPEHUWKDWLIWKHFRQGLWLRQLVWUXHWKHQWKH
FRGHH[HFXWHVZKDWoVLQWKHEUDFHV,IQRWLWFRQWLQXHVRQLWVPHUU\
ZD\6HHZKDWHOVH\RXFDQFRPHXSZLWKXVLQJLIDQGDFRPELQDWLRQ
RIORRSV

www.pclpublications.com 13357
(BNF;POF

8IFUIFSZPVMJLFCMBTUJOHUIF
CBEEJFTXJUIBTFSJFTPG
FWFSNPSFQPXFSGVMXFBQPOT 
UBLJOHUPUIFUSBDLTJOFYDJUJOH
SBDFSTPSTBWJOHUIFXPSMEJO
TUSBUFHZUJUMFT UIFSFTTPNFUIJOH
IFSFGPSZPV*GZPVSFBEFTLUPQ
HBNFS DIFDLPVU-JGFJT
4USBOHF 'PPUCBMM.BOBHFS
BOENPSF'PSNPCJMF
HBNFST UIFSFTBXFBMUIPGUJUMFT
JODMVEJOHIJHITQFFEBOE
TFSJPVT4USFFU,BSU3BDJOH UIF
DMBTTJD9$0.$PMMFDUJPOBOE
BNB[JOH5IF6OGJOJTIFE4XBO
BioShock 2 Remastered
Big Daddy is back and has never looked better.

Info//
A
lthough Apple has constantly pushed There’s no doubt that BioShock 2 is still great.
and developed the Mac’s ability to deliver The future-noir setting and the art style impress,
Feral Interactive
a gaming experience akin to their PC and the game offers everything you would expect
feralinteractive.com
counterparts, when held in direct comparison, the from the franchise. A cinematic single-player mode,
£19.99, $19.99, 19.99 €
software differences are crushing to all those that numerous multiplayer modes and all the expected
have chosen the Microsoft gaming route. At the DLC. BioShock 2 retains everything fans would
FPS genre’s inception, PC gamers could immerse want, and for those readers, there will be no further
themselves in the depths of hell with Doom while motivation needed to hit the Buy button.
we Mac owners tried to convince ourselves that
Marathon was just as good. It wasn’t! The Mac has
never been considered a gamer's machine, yet over
the years the blurring of the internal specs and the
sheer horsepower of Apple’s machines has made
bigger, better games possible. Why haven’t we seen
a balance between big-name Mac and PC games?
Take, for example, Feral Interactive’s Mac release of
the fantastic 2016 game, BioShock 2 Remastered.
Mac gamers shouldn’t really be heralding the
positives of a re-issue, we should be sharing the
same soapbox as PC gamers moaning how broken
Cyberpunk 2077 is!

Who’s the daddy? BioShock’s Big Daddy is one of the most awesome FPS villains ever.
Save them or rob them? Watch out for the Little Sisters.

BioShock fandom aside, this is a polished port


of a dated but still enjoyable game that delivers
the expected thrills and lifespan those familiar with
the series would expect. Despite this, if you remove
the nostalgia by placing this game in the hands
of a first-time desktop gamer, BioShock 2 quickly
shows its increasing age; new coat of paint or not.
Worse still, when placed alongside contemporaries
on Windows-based hardware, for those taking
their first swim in the BioShock waters, the overall
feeling will be that sinking sensation of being
short-changed. How much longer will we have to
wait until games developers treat the Mac with the
respect it is so richly deserves? I for one am getting
very bored with dining off the scraps! JG

Verdict//
PROS AND CONS:
+ Intense Single Player
+ The cyberpunk stylings
endure
- Feels very dated
- The genre has moved on
LAST WORD
When a ten-year-old game
with reworked visions and
some additional DLC sits
at the pinnacle of the first-
person shooter genre on
the Mac, questions need to
be asked.
RATING: 3/5
Life is Strange 2
The line between video games and movies is further blurred.

Info//
I
f you've played the original Life is Strange, The small-town setting of the original is scrapped
you'll be instantly at home with this sequel. in favour of a forced road trip as the brothers make
Feral Interactive
The game mechanic hasn't changed; it's still a their escape, and Max's ability to reverse time
www.feralinteractive.com
narrative-driven graphic adventure with the story gives way to Daniel's telekinetic powers - moving
£32.45, $39,95, 39,95 €
interrupted – and guided – by regular multiple- objects with his mind. This comes in very useful
choice options. These choices define the path the as you make your way south and is frequently
storyline takes and directly affect how it plays out. essential as you tackle the puzzles and pitfalls that
Like the first game, it's episodic, with the story split abound in this well realised graphic adventure.
into five, self-contained chapters. However, this But one thing that stands out in the new game
Mac version bundles all five together; we don't have as well as being the key strength of the first, and
to keep waiting for the next one to be released, its prequel, Beyond the Storm, is the superb
as did console and PC gamers when it came out characterisation and settings; you really get to
on those formats. It features a protagonist with a know the Diaz brothers and become genuinely
supernatural ability too. invested in their fates. Set against the backdrop
But for all its similarities, there's plenty that's of the 2016 American election, it covers issues
new here too. The title no longer centres on such as racism and morality with sensitivity and
college girl Max(ine) Caulfield. Instead, you control intelligence and, though the overall storyline is
the brothers Sean and Daniel Diaz, as they deal more complex than the previous games, it loses
with a personal tragedy when their father is killed, none of its depth. IO
and they're forced to go on the run from the law.

Verdict//
PROS AND CONS:
+ Great characterisation
and plot
+ Easy to get into
+ Looks amazing
- We miss Max Caulfield
LAST WORD
A beautifully realised
game wherein the twin
protagonists do more
than provide an avatar
for the player. Definitely
recommended.
RATING: 5/5
A game you can read or a novel you can play?

Info//
W
hat a lousy start to the day. You wake up Naturally, there are puzzles to solve. How do you
in a strange apartment, stark naked and get into the briefcase with the combination lock?
Plug In Digital
covered in blood with a wound to your How do you open the safe? What’s the significance
https://unmemory.info
ribs and a dead body in the bathtub. You have no of the painting on the wall or the copy of Alice in
£5.99, $5.99, 6,99 €
idea where you are or how you got there. What are Wonderland with certain letters circled? And that’s
you to do? just the first chapter. Listen out for audio cues too,
Unmemory, the first game from a small team in like the TV in the next room, someone knocking
Barcelona, offers a great new take on the text and on the door or the telephone ringing. Because of
graphic adventure. There’s a lot of reading to do but the importance of these audio cues and the need
don’t let that put you off. The story is well written for spotting clues, the game is best played with
and engaging; and really draws you into the strange headphones on and a notebook in your hand but
world of the protagonist. Every few paragraphs, the the choice is yours.
text is interrupted by a graphic of something nearby. Maybe the puzzles are just a little contrived, in
You can frequently interact with these graphics, that they’re clearly deliberately set up to be solved
sometimes immediately, sometimes later in the rather than happened upon in the real world. As
story after another clue is revealed. Scroll back up a result, the game feels more like a digital escape
and try again. The game is arranged in eight bite- room than a real-life detective case. Not that this is
sized but substantial chapters, so you never have to a problem; it doesn’t make the game any less fun.
scroll too far to find the object you passed earlier but It’s exciting, original and a great way to spend a few
need now. hours on your tablet or smartphone. IO

Verdict//
PROS AND CONS:
+ Very original
+ Engaging plot
+ Exciting and fun
- Puzzles just a little
contrived
LAST WORD
A great new take on the
adventure genre that will
appeal to those who like
their gaming cerebral.
An early puzzle involves finding the
Well written text is interrupted by interactive graphics. Can you find a clue? combination to a locked briefcase. RATING: 4/5
Street Kart Racing
Race at 80mph, just an inch above the asphalt.

Info//
T
his is more than just a racing game. It’s an Battle your opponents in week-long tournaments,
entire online community. Three years in the earning promotion or suffering relegation
Fat Cigar Productions Ltd
making, the multiplayer-focused Street Kart depending on your performance.
www.streetkart.me
Racing lets you race with other kart drivers from To get the most from your kart you can set it up
$1.99, £1.99, 2.29 €,
60 different countries and keep up with the latest to suit your driving style, as well as optimising its
with IAP
goings-on in a very well populated Facebook group performance for twisty or straight tracks, wet or dry
dedicated to the game. Just the thing if you’re conditions and hot or cold weather. Apart from this
a competitive racer who likes going up against setup, the karts are identical; same engines, same
human beings rather than AI drivers. That’s not to equipment, same chances of winning. You won’t
say you can’t race computer-controlled opponents, get lapped by a mediocre driver who’s spent a real-
though. You build your career by racing them in world fortune on buying the best bits and pieces for
Cadet Karts. his vehicle, like you do in some games.
It’s not for the faint-hearted. Street Kart Racing That’s not to say there are no in-app purchases.
is a serious simulation game designed with the You can buy ‘Aces’, an in-game currency which can
help of professional kart racers to be as realistic also be won in tournaments or earned by watching
as possible. Don’t expect to drop bananas on the advertising videos. You can use it to unlock items
track or fling turtle shells at your opponents here. and generally speed up the game but they’re far
Instead, you’re in for no-assists, no-excuses real- from essential and can’t be used to give you an
time tournaments on recreations of genuine tracks. unfair advantage in races.

On the starting
grid. Ready,
steady, GO!
Race against opponents from all over the world.

In-game weather conditions are real-time,


based on the weather at the real-world course. If
it’s raining at Adria, for example, it’s also raining at
Adria in the game. Do you wait for the rain to stop
or set a time now in case the rain gets worse?
Regarding the game as its played, as long as
you use a recent tablet or smartphone the graphics
are pretty good but not on a par with Forza or Gran
Turismo. At this price, you wouldn’t expect them to
be. Where the game really shines is in the driving
physics. Pair up a decent joypad as a controller and
you really feel you’re in control of an 80mph kart;
and sitting just an inch above the track.
Our only real complaint is it’s impossible to use
the same account on more than one device, so you
can’t (for example) play at home on your tablet
and use your smartphone on the train. Apart from
that, the game’s a must-buy for fans of real-world
multiplayer racing. AH

PROS AND CONS:


+ Excellent driving physics
+ A very social game
+ True to life
- Confusing price structure
LAST WORD
Seat-of-your-pants driving
on mobile devices doesn’t
get any better than this.
Ideal for those who like
realism in their racing.
RATING: 4/5
The First Tree
Can you out-fox this curious walking sim?

Info//
T
he First Tree had an unusual inspiration. from the estranged son’s childhood. Dig them
Its developer, David Wehle, used it as a up for wistful commentary from the boy himself,
David Wehle
‘creative outlet’ to deal with his becoming now grown up and conversing with his wife as he
http://www.thefirsttree.com
a father for the first time; and also losing his own recalls his early life with his father and how they
£4.99, $4.99, 5,49 €
dad. So naturally, family ties play a large part grew increasingly apart.
in this third-party exploration game. It centres Unfortunately, the game’s excellent
around two parallel stories; a fox (the playable atmosphere isn’t matched by the gameplay.
character) trying to find her missing family, and There’s simply too much traipsing around looking
through narration, a son reconnecting with his for something to do and not enough to engage
estranged father in Alaska. Along the way, you the player. There are no enemies to fight, no
uncover artefacts and stories from the son's life environment hazards, no puzzles to solve and no
as he becomes intertwined in the fox’s journey secrets to uncover (the digging sites are clearly
towards The First Tree. signposted). There’s a little platforming to be done
Graphics are simple but enchanting, giving a but it’s very basic and unimaginative.
real sense of being there when combined with the The First Tree is short (a couple of hours, a little
melancholy music. As you run through the snow- more if you want to grab every star) but that’s a
kissed plains of Alaska, a beautiful fern forest and blessing rather than a limitation. It has a lot of
more, you gather stars liberally scattered through heart and soul but not much gameplay and so is
each level. You must also keep an eye out for unfortunaltely boring. AH
patches of freshly dug earth that conceal items

Switch to Commentary Mode for


Dig, fox. You might find something regular observations from the author.
belonging to the boy.

Verdict//
PROS AND CONS:
+ Atmospheric
+ Good music
- Too little to do
- Clunky mechanics
LAST WORD
Atmospheric aesthetics do
not make up for the lack of
gameplay. It just isn’t fun. Controls are a virtual joystick and
a jump button. They work well.
RATING: 2/5
When is a game not a game?

Info//
W
hen attached to a game, the phrase for the next scene or tapping it for the next line of
‘interactive visual novel’ often rings alarm dialogue. There’s nothing that challenges your
Annapurna Interactive
bells. Too many titles of this ilk boast great dexterity or problem-solving skills. Aside from a
https://annapurnainteractive.com
storylines but no gameplay. Unfortunately, this is all few multiple choice options at the very end, there’s
£4.99, $4.99, 5,49 €
too true here. nothing approaching a game here at all. I’m sure
If Found... gets off to a bad start. After a sequence the developers would argue this is a design feature
involving a space ship flying past Jupiter and finding rather than a design fault and that If Found... was
a black hole, there’s a barely-interactive trawl never meant to be a game; but it didn’t work for
through the diary of the protagonist, Kasio, covering me. There are much better executed examples of
the whole month of December. You just read an interactive fiction out there.
entry, wipe it away by dragging your finger over The storyline is engaging enough to keep you
the screen and then do the same on the next page, reading (‘playing’ would be an exaggeration) for
stopping just long enough to turn the volume down; the two or three hours it takes to get to the end
the background music at this point sounds like a bad but if you took the developers’ promise of ‘brand
feedback loop. new gameplay mechanics’ at face value, you’ll
While the aesthetics soon improve, with hand- be disappointed. It’s simply a character story and
drawn pictures and relaxingly soft music, the one that would be better realised as an illustrated
‘game’ itself doesn’t. It’s all just wiping the screen novella. DA

Verdict//
PROS AND CONS:
+ Passable storyline
+ Nice artwork
- No gameplay
- No replay value
LAST WORD
An interactive story
that’s very light on the
‘interactive’. There’s better
out there.
RATING: 2/5
You spend a lot of time wiping away one scene to reveal the next.
The Unfinished Swan
Can you paint a world to life?

Info//
R
emember the mazes in those old fashioned But why? You play Monroe, a ten-year-old
text adventures, where every location had orphan whose recently deceased mother painted a
Annapurna Interactive/
the same text? Remember how you found lot of pictures but rarely finished them. His favourite
Giant Sparrow
your way around by dropping objects to mark your painting was an unfinished swan. When the swan
www.giantsparrow.com
way, so you could map the maze and find your way stepped out of the picture, Monroe follows its
£4.99, $4.99, 5,49 €
out? The Unfinished Swan starts a little like this but footprints into a surreal storybook kingdom.
with graphics. The first thing you see is a plain white It’s a colourless journey at first but you soon
screen. After experimenting with the controls for a find the swan has left yellow footprints. Where do
while, you find you can fling black paintballs which they lead? Along the way, you might find letters,
spatter over the 3D environment, highlighting picked out in red. These give you a piece of the
walls and openings. Soon you’re walking around storyline, so make sure you collect them. The
first-person shooter-style as more and more of your heart of the game is finding your way around using
surroundings are so marked. your paintballs but this involves some significant

The introduction of
shadows later in the game
makes it easier to find
your way around, but the
puzzles continue.
Find out more about the kingdom by gathering letters, through which the story unfolds.

puzzles too. How do you get onto the ledge which couple of hours to complete, which is about right
is too high for your jump button? Can you find for a quirky indie game such as this but if you
your way around the lake, which swallows thrown haven’t had your fill, there’s plenty of reason to
paintballs without showing your way? How do play it again. There are easter eggs to be found,
I get out of the watchtower? I seem to be going along with balloons that can be collected and
around in circles. Later in the game, shadows are used to buy in-game items.
introduced to solid objects, helping you find your The Unfinished Swan is a beautiful, laid-back
way, but the puzzles continue aplenty. experience. A gentle, yet challenging alternative to
The game as a whole won’t take more than a racers and blasters that won’t break the bank. AF

Verdict//
PROS AND CONS:
+ Very original
+ Perplexing puzzles
+ Beautiful aesthetics
- A little short?
LAST WORD
Serene music, lovely
minimalistic visuals and
challenging gameplay
make this a great
for smartphone and
(especially) tablet gamers.
RATING: 5/5
FAR: Lone Sails
Embark on an epic journey to; where?

Info//
T
his sort of game could only happen in the What caused the apocalypse is only ever hinted at
digital delivery era. Can you imagine such and why you’re driving a beautifully realised land
Mixtvision Games
a quirky and unique title, that takes only yacht along the shattered coast of the old seafront
www.far-game.com
three or four hours to complete, appearing on a isn’t explained. Gamers are driven not by a plot and
tablet and iPhone: £3.99,
Nintendo cartridge? Or even a PlayStation CD? Yet a preferred outcome but by their own curiosity and
$3.99, 4.99 €
as an inexpensive digital download for computers, imagination.
Mac (Steam): £11.39,
consoles and mobile devices, it’s perfectly placed. And the game? You play a small girl wearing
$14.99, 14,99 €
FAR: Lone Sails is described as ‘a zombie-free a bright red coat and hat, presumably to make
post-apocalypse’ game. Civilisation has crumbled you stand out against backdrops of minimalistic
but there are no hordes of undead roaming the colours. The coat also billows out to arrest your
wastelands. Nor indeed hordes of anything else. descent, allowing you to fall any distance. As arcade
Aside from yourself, there are next to no life signs at adventures go, this one’s more ‘adventure’ than
all; just dried-up seas and the ruins of civilisation. ‘arcade’. It’s a side-scrolling, 2D affair realised with
some gorgeous hand-painted graphics. You can
walk right and left, jump and pick up/drop one
object at a time. Very quickly after the opening
scene you find the aforementioned land yacht and
climb aboard. When inside the interior is revealed
through a cut-away perspective but can you work
out how to get it moving?
As you journey through what’s left of the
lands, you must keep your vehicle running with
repairs, fuel and upgrades as you tackle a series of
environment-based puzzles that threaten to halt
your progress. And that’s all we’re telling you. The
rest is for you to find out.

The game starts with a burial. With your


companion gone, it’s time to move on.

When in your land yacht, the interior is


shown as a cut-away drawing.
One of the many
environment
puzzles. How do you
get your vehicle over
this bridge?

As well as the desktop, tablet and smartphone,


Verdict//
PROS AND CONS:
FAR: Lone Sails is also available on the PC, PS4,
+ Beautifully atmospheric
Xbox One and Switch but you can’t pick up on one
device and then continue on another. As it’s the + Gorgeous art
same game on each except for the control inputs,
+ Keeps you guessing
there’s no advantage in having it on more than
one platform. Given the price difference between - Expensive on Mac
the desktop and mobile version, we recommend
LAST WORD
playing it on the tablet.
Engrossing and beautifully
Perhaps the game’s greatest strength is it
realised but short. It’s an
tantalises for just the right amount of time. It’s
epic ride while it lasts,
hard enough to give a sense of achievement when
though.
you solve a puzzle but not so hard you feel stuck
and frustrated. That’s how an adventure game RATING: 4/5
should be. IO
Football Manager 2022
There is too much money in the beautiful game, and that’s just in-app purchases!

Info//
T
he football management simulation has SEGA’s Football Manager 2022 is far more than
been a huge part of the sport gaming genre a reality check, in a “I’m somehow even worse
SEGA
since the early days of eight-bit computing; than your current gaffer” way. It’s a complete
www.footballmanager.com
for a really simple reason. Being an armchair immersion into the running of not simply a team
£39.99, 54.99 €
pundit, manager, player or anything really, just as but the entire club. The scope of the options
long as you can work on your sofa’s butt groove and the teams available is frankly stunning; and
at the same time, is the best job in the world. You the depth, though initially overwhelming, feels
answer to no one, you’re paid well in self-worth unparalleled. The processes behind the running
and, most importantly, you’re always right despite of the club are as expansive as they are detailed,
whatever you’re told to the contrary. from the development of the youth squad to
Obviously, as armchair football managers go, delivering a positive press conference to boost
I’m one of the best! Each week, I know better than club morale. The wealth of options is stunning,
the current gaffer of my beloved football team, spanning 50 nations and over 25,000 clubs, from
be it squad, formation, transfers or even the away first team to academy level.
kit. Under my leadership, we wouldn’t be facing This year’s annual tweaks and changes are
relegation we would be looking toward Europe capped with a usable and massively helpful tutorial
next season at the very least. Right? Wrong! option, a basic that has been lacking for a long time.

The crowd scene was obviously digitised before the COVID lockdown.
Also, close to the top of the enhancement league is Sadly, a very unwelcome addition is the Analyse your team’s performance and
see if you can do better next Saturday.
the improved UI, removing a few of the click-through inclusion of DLC really early in the game! I hope this
bottlenecks that make a world of difference. The isn’t the shape of things to come, as ask anyone
in-match and post match stats are wonderfully over the age of 60 and they’ll gladly tell you “money
overwhelming, allowing you to plug holes in your has ruined the game.” SEGA, please listen.
game plan. Your backroom team feels more ‘real”’ Another weaker area, which is exasperating
in this instalment, offering useful feedback and considering the staggering depth of realism
not plucking random cliches from the archives. elsewhere, is the in-game player visuals and faces.
Alas, so do the player’s agents, thus making a good The animations are OK but the faces are so lacking
relationship between you both essential to landing in detail and basic human connection, only a
that big-name signing. Relationships make up such developer’s mother could love them.
a massive part of the team-building experience that Has SEGA done enough to collect your transfer
drives a team to glory. fee for the 2022 update of the Football Manager
SEGA has added a tone-of-voice option for you
to deliver your pre-match speech and interact with
individuals. I can only assume this really is football
series? Perhaps. It’s a significant step up in many
areas, though not essential if you’re still playing
the 2021 game and don’t want to shell out on the
Verdict//
PROS AND CONS:
at club level and it’s amazing. new one. JG
+ Stats and options deeper
than Man City’s pockets
+ The fantastic tutorials
help you master the
gameplay
- Requires a huge
investment of time
- Match day replays are
underwhelming
LAST WORD
A great trip to the
boardroom, training
ground and beyond of
your choice of the world’s
football teams.
RATING: 4/5
Puppoz
Yap! Yap! Yap! Pop!

Info//
W
hen you’re sick of blasting aliens, open the next one (there are 15 in total) and
dismembering enemy combatants and earn money to buy faster puppies. There’s three
Superstar Games
generally leaving a blood-soaked pathway to unlock. Features include bonus levels, a
www.superstargames.co.uk
in your mobile gaming wake, try Puppoz. It’s free skateboard to improve your speed and ‘mazes’,
Free (ad supported)
and it involves nothing more violent than dogs where you place your dog on one of four paths in
popping balloons. the hope it will find a treasure chest at the end.
The aim of the game is to use the on-screen Time limits are tight – expect a challenge.
virtual joystick to guide your puppy through Puppoz is cute; the kids will love it. It’s not a
a timed course, bursting balloons on the way. game you’ll be playing for months but as it’s free
Complete a level by popping every balloon to with no in-app purchases, it doesn’t have to be. AF

Guide your mutt using the on-screen virtual joystick.

Verdict//
PROS AND CONS:
+ Completely free
+ Cute
+ Good graphics and sound
- Limited lastability
LAST WORD
A game that’s fun to play
and costs you nothing. Any
questions?
RATING: 3/5 Grab a skateboard for extra speed and a paw print for a bonus round.
Info//
Mojang
Explore and populate your very own little world. www.minecraft.net
£6.99, $6.99, 6,49 €

B
uilding and world-creation games have always wide world to explore beyond the blocks. Jump into
had a uniquely addictive quality that other the Marketplace to learn new skills, share community
genres can’t quite replicate. Sim City first creations and get access to all-new and evolving
showed gamers it could be fun to build as well as downloads from other creators.
destroy, then the legendary Peter Molyneux came In many ways, Minecraft is the perfect mobile
along and took things a step further with the equally game. The pace is whatever you want it to be. You
legendary Populous. can dip in whenever you like and have a quick play
Minecraft has built up a dedicated following or spend more time roaming around re-modelling
on every platform possible, with its mix of puzzles, your creations and your world until your heart’s
survival and building. Yet it has never felt more content. With a vast community to delve into, the
at home, to this reviewer at least, then on the game constantly feels new and improved. As a
smartphone and tablet. The concept is – at first – detractor for the longest time, this latest generation
very simple. The game throws you into a randomly of Minecraft feels more rounded and expensive than
generated, geometric world made up of cuboid ever, without diluting what attracted millions to the
blocks. There are trees, rocks, grass and water but all game in the first place. In conclusion, give it another
are created from different kinds of blocks. Holding try! JG
your finger on a block for a few moments destroys
it, allowing you to sculpt the world to your liking.
You have access to a wide range of different types
of block which you can place anywhere to create
structures, the simplicity or complexity of which is
only limited by your imagination and creativity.
Minecraft features day and night cycles, a survival
mode and monsters; which all give it more of a
focus. It’s one thing to build a world, it’s another to
live in it. It’s not simply about building. It’s like having
a LEGO set in your pocket, that you can share with
your friends. This might sound boring but it’s actually
a lot of fun just trying to build the most impressive
and imaginative structures you can conceive and
then show them off. That’s just the start. There’s a

Verdict//
PROS AND CONS:
+ Huge variety of features
+ A vast world in and out of
game
+ No in-app purchases!
- Too much freedom for
some.
LAST WORD
During these uncertain
times this is a very
therapeutic way to pass the
time, even if this concept
hasn't previously turned
your head.

Minecraft pandas to your every need (ouch!) RATING: 5/5


Tetris
Dull! A word one would never associate with the best puzzle game of all time?

Info//
F
or a long time, I ignored the advice: "The app versions of Tetris were being removed from
is best experienced via headphones." And that the App Store, there were high hopes that the
N3TWORK Inc.
was silly of me. Audio hasn't played a huge next developer to pick up this golden goose of
n3twork.com
role in my mobile gaming. Let me explain. The gaming would maintain the high standard of its
Free (IAP)
touchscreen of my tablet, or smartphone, activates predecessor. The simple fact is that Tetris is one
an invisible barrier between myself and my wife's of the most intense games ever to stand front
inane droning, aka telling me about her day. The and centre with EA's titles, with both the visuals
inclusion of sound would break the spell and alert and the sound reflecting this. These games were
her of my utter lack of interest and force me to pay Tetris at its most exciting and overblown and were
attention. Having the realisation that sound – via brilliant. Alas, this version takes the opposite route
headphones of course – plays such an important and attempts to rebrand Tetris as a chill-out game.
role in the immersion into my gaming has done The customisable (at a price) visuals are flat and
little to improve communication with my spouse. uninspired, even down to the trope of offering
Yet it's a small price to pay to experience mobile a Game Boy black-and-white version. As for the
games as they were intended. sonics and the soundtrack, they're more akin to a
Having stressed how audio can enhance a 4 am ambient set on an Ibiza beach, not a thrilling
game, I believe we have a first with the latest puzzle game. Ill-conceived feels generous. With
incarnation of the puzzle-classic Tetris to hit iOS. the audio off, the core gameplay still holds the
This game needs a start-up message stating, "The attention, but if that's the best compliment I can
game is best experienced with the volume off." think to offer a Tetris game, something has gone
After the announcement that EA's various very wrong. JG

Verdict//
PROS AND CONS:
+ It’s Tetris
- The art style doesn't
appeal
- The soundtrack is awful
- A massive step down in
quality
LAST WORD
Imagine the shark attack
scenes from Jaws overlaid
with the SpongeBob theme
music, not the classic
score. Distracting, right?
RATING: 2/5
Info//
When is the NES classic Tecmo Bowl not the NES classic? New Star Games
namestargames.com
When it’s Retro Bowl on the iOS. Free (IAP)

C
learly inspired by the much-loved Nintendo Entertainment
System’s Tecmo Bowl, UK-based developers New Star
Games’ Retro Bowl take on the NFL. - /0-)./* (*Ȅ.
staple of gaming. Much like soccer, with the development and
Verdict//
PROS AND CONS:
advancement of the hardware on which we play, the pick-up-
+ Solid gameplay and
and-play fun has been diluted by realism. This is certainly not the
options
case here. The casual style is a perfect fit for iOS.
Gameplay is split into two genres; Roster management + Great visuals and
features press duties and maintaining the egos and fitness of soundtrack
your players (try to keep them fit, as an injury lasts forever!) The
+ Bargain purchase price
second is based on the playing field.
Although featuring a full roster of teams, players and tactics, - The injuries system is far
the gameplay and the plays themselves are limited but always too harsh
fun. The retro style of the visuals are also a MVP (Most Valued
LAST WORD
Player) in the appeal to this gamer and those who are familiar
A fun mix of management
with its NES inspiration. The free edition offers a pleasingly
sim and arcade-style
in-depth look at both the semi-manager mode and the core
gameplay that will appeal to
gameplay, which should provide you with enough motivation
the casual fan.
to invest a tiny amount to purchase the full unlimited version.
If you're looking for something new to add to your Sports app RATING: 5/5
collection, this should score a touchdown for most fans. JG

Info//
Good Job Games
goodjobgames.com
Do you have what it takes to call yourself a touchscreen Free
Ninja Warrior? Err, sorry: an Epic 3D Racer?

A Verdict//
s a film bore, I take huge joy in spotting onscreen references
to other flicks or catching the unofficial inspirations for those
'mockbusters' that litter the darker recesses of Netflix. Good Job
PROS AND CONS:
Games' Epic Race 3D doesn't look to the silver screen for its obvious and
+ Smashing by simple
COMPLETELY unlicensed inspiration. Instead, it turns to the TV.
visual style
Epic Race 3D takes its inspiration from Ninja Warrior, or American
Ninja Warrior, or Sasuke in Japan; a gameshow that pits contestants + Large variety of events
against a huge and increasingly tough series of obstacle courses, with to play
more than a dash of parkour and insanity. In any of its guises and
+ Loads of unlockables
locational re-brands, it’s brilliantly fun and unmissably entertaining.
The game follows the basics of the TV show, albeit in smaller, bite-sized - Oh my goodness those
chunks of two or three obstacles per race. Each contest has the player &^%$ing ads
facing CPU-controlled opponents, with the loser eliminated, until
LAST WORD
the last player is declared the winner. Repeat. Your rewards are new
Toilet-break games don't
obstacles, unlockable costumes and victory dances, which also appear
come much more enjoyable
to take unlicensed inspiration from pop culture.
than this one. Just don't
There isn't really much to do here. The single-touch gameplay
expect much more than a
testifies to this, but what's here is great, and fans of the TV show will
quick burst.
undoubtedly find much to enjoy. Alas, the massively obtrusive adverts,
which are unleashed to stomp all over the goodwill the gameplay RATING: 4/5
inspires after each race, grate! JG
XCOM 2 Collection
The awesome tactical RPG blasts onto iOS devices.

Info//
W
ow. Just... wow. Not only has the back, and that’s where you come in. Piloting the
awesome turn-based tactical game Avenger, a captured supply barge kitted out as
Feral Interactive
XCOM 2 been released for the tablet and XCOM’s mobile base, you must take the fight back
www.feralinteractive.com
smartphone, but it’s a hugely impressive port with to the aliens.
£23.99, $24.99, 27,99 €
very few concessions made for the transition, and a Experience with the original XCOM is useful,
huge amount of additional material included with but far from essential. Newcomers will have no
no further purchases required. Along with the main trouble picking up and playing XCOM 2. There’s
XCOM 2 game, The XCOM 2 Collection gives you four an excellent tutorial that gets you started, and the
DLC packs and the War of the Chosen expansion rest is picked up as you go. Veterans of the alien
pack. At the price, that’s a bargain. war will find this new release offers more of the
Set in 2035, 20 years after XCOM – Enemy same, with some great new additions such as the
Unknown and XCOM – Enemy Within, this sequel Chosen, three types of elite alien/human hybrid
assumes the humans lost the war. Aliens now enemies; and the Lost, unaligned zombie humans
rule the Earth through the puppet ADVENT who attack aliens and resistance fighters alike.
Administration, and most XCOM members Although XCOM 2 Collection can run on both
submitted to their rule. But not all. There’s an tablets and smartphones, as you’d expect, it’s best
underground resistance dedicated to fighting played on a tablet. The more powerful your tablet,

Fire from defensive cover, and make your shots count. Out-flank the aliens if you can.
Stay hidden as you move around the
map. Fighting from behind cover
the better, of course. With a modern tablet you instinctive. As you progress through the game, makes you harder to hit, and if an alien
can achieve 30fps and virtually no reduction in you get to direct research projects to create new can’t see you, he can’t shoot you.
graphical compromises, an excellent achievement weapons and tools. Your squad gain experience as
on a mobile device. they go too. Be sure to promote them when ready,
Of course, none of this would be worth a spent so they can improve their abilities and gain new
shell case if the game wasn’t fun to play, so you’ll ones. Then when you finish the game, you’ve lots of
be glad to know it is. Lots of fun. Its intense, turn- DLC and an expansion pack to download without
based action keeps you on the edge of your seat, paying anything.
the gripping storyline makes you want to find out With far too many mobile games seemingly geared
what comes next and new elements are introduced around encouraging you to make in-game purchases,
as you go, keeping you on your toes. The user it’s refreshing to see a company like Feral releasing
interface is perfect for a touch-screen tablet; don’t high-quality, pay-once titles like this. It’s an excellent
be fooled by how complex it looks. It soon becomes release, and a bargain at the price. IO

Verdict//
PROS AND CONS:
+ Great technical
achievement
+ Huge amount of material
+ Great value for money
- A little on the hard side
LAST WORD
An awesome in-depth
strategic shooter that
really gets the brain
working.
RATING: 5/5
Medieval IIǽ*/'-
Can you become the Middle Ages’ most feared warlord?

Info//
Feral Interactive
www.feralinteractive.com
£12.99, $14.99, 14,99 €

F
eral Interactive’s Mac and Apple mobile unlocked by defeating them in the main campaign
conversions of SEGA’s Total War strategy games game, or by completing the campaign as one of the
have quite a following. Fans of the franchise have starting factions. As well as the campaign option,
long lauded Medieval II as one of the best, perhaps you can play quick battles, recreate historic conflicts
the best game in the series; and it’s now available on and fine-tune the presets in a custom battle, so
the iPad and iPhone as a universal app. We wouldn’t if you’re only keen on getting your hands dirty in
recommend playing it on a regular-sized iPhone, combat, there’s plenty to see and do. Conversely, if
though. It’s far too fiddly on the small screen. the campaign strategies are all that appeals to you,
Set in the Middle Ages, the action takes place battles can be auto-completed using the game’s AI.
across three continents – Europe, North Africa The iPad/iPhone version of the game offers
and the Middle East – as 17 playable factions vie everything included in the PC release, with the
for supremacy. Six factions are available at the exception of the multiplayer game. There are no
start; England, France, Venice, The Holy Roman plans to add this later, though the PC’s Kingdoms
Empire, Spain and The Moors. The other 11 must be DLC is coming to mobile devices soon.

Fleeing units are especially


vulnerable to cavalry charges.
The Campaign Map, where
you move your armies, recruit
troops, build cities and more.

Battle stations! way. Unfortunately you can’t switch to an overhead


The game’s battles are executed in real-time. view, which would be graphically less impressive
Instruct your troops where to move, who to attack but more practical at times.
and so on, and they do so, straight away. You It can be tricky to see who’s who on the
can speed up or slow down the action, so you’re battlefield, but that’s the fog of war. You must
not bogged down with boring marches, and also keep a keen eye on what’s going on, like any good
pause the game to give orders, which are executed general should. It’s also sometimes tricky to tap
when you restart. Success depends on using the thing you want, for example, tapping a city on
your units, such as cavalry, archers, spear men the Campaign Map when you have a captain in
and more, to their best advantage and exploiting front of it. You get used to this with time, though.
weaknesses in your AI opponent’s strategies and Total War: Medieval II is more expensive than
positions. most iPad/iPhone games, but in our opinion,
Away from the battlefield, on the Campaign it’s good that Feral is charging a fair price for
Map you build cities, raise armies, manage sieges the entire game as a one-off purchase, instead
and enter into battles. Here the game is turn- of working a lucrative but annoying pay-to-win
based; you move your armies one at a time, then system into it.
click an icon to end your turn. Only the areas you If you liked previous Total War games, you’ll love
occupy are shown in full; the rest of the map is this. If you’ve never played one but are interested in
fogged, becoming clear as you explore. doing so, now’s your chance. If you’ve played one
The user interface is excellent. Everything is before but hated it, Medieval II is unlikely to win you
at your fingertips. Like all good strategy games, it over. It’s a superb strategy game, but not for arcade-
can take some getting used to, but there’s a good orientated button-bashers. IO
tutorial mode available. It does a great job of
introducing you to the game’s workings, though
I did blanch a little at having to help William the
Conquerer defeat Harold at Hastings on the Battle
Verdict//
PROS AND CONS:
Map, then take London and Nottingham on the
+ Great presentation
Campaign Map.
+ Comfortable interface
+ In-depth action
Quick, march
The game engine performs really well. It’s super- - No multiplayer
speedy, and copes admirably when the battle
LAST WORD
intensifies. You can zoom the camera in for a closer
A truly excellent game that
look or out for a wider field of view, scroll around
won’t appeal to everyone,
the battlefield to keep track of your units and
but is ideal for those who
raise, lower or rotate the viewpoint to get around
prefer a more cerebral title.
something that’s blocking your line of sight. This is
especially useful when the action moves into a town RATING: 5/5
or castle, where walls and structures often get in the
Cut The Rope: BLAST
How to ruin a franchise in one lazy step!

Info//
D
o you remember a little green monster who Where’s the Rope?
lived at the bottom of your iPhone’s screen? Cut the Rope was a genre favourite thanks to
SKYWALK
He was just about the cutest little monster its finely balanced and highly addictive puzzle
www.skywalkgames.com
ever. Om Nom was his name, and he was rather gameplay, which still keeps you going to the end.
Free (IAP)
hungry; famished, in fact, and if you didn’t feed It’s an ideal game to dip in and out of, and looking
him up pronto he might just waste away. You didn’t at the sales, many still do – me included. So the
want that on your conscience, right? I certainly announcement of a new match-three puzzle game
didn’t, and I wasn’t alone. spin-off was the source of some excitement. How
Om Nom and his Cut the Rope series went from could the classic gameplay style fuse with the sub-
strength to strength, not only on the App Store. genre made popular by Candy Crush Saga and its
Cartoons, toys and the usual merchandise turned many pretenders?
heads for a while until the series’ mainstream For those of you that have never played Candy
appeal waned, returning the series to its gaming Crush Saga, how’s the weather on Mars? Let me
origins. Fortunately, the game itself was brilliant! It bring you up to speed. This massively popular puzzle
was 250 levels of rope-swingy, physics-based puzzle game has you swapping sweets to make lines of
gameplay that kept you well entertained. three or more units, which then disappear. Match
The basic idea was to sweep your finger across four or five sweets for a special candy piece and beat
the screen to cut ropes (hence the title), and drop each level to move on to the next. Sounds simple,
suspended sweets into the hungry Om Nom’s doesn't it? It’s not! Candy Crush Saga is a massively
mouth. However there was more to it than that, entertaining game that appeals to all gamers not
with stars to collect which are required to open up matter of age or tastes. This app still personifies the
new worlds, of which there were four in total. Puzzle genre at its most annoying and addictive.
Now imagine the above, mixed with the
personality and gameplay mechanics of the Cut
the Rope. This is the gaming equivalent of mixing
chocolate and peanut butter! How could this not
be the best puzzle game ever? This union was
seemingly impossible to get wrong, but sadly,
developers SKYWALK have achieved the impossible.
Not only is their game a basic and frankly lazy rehash
A tragic misstep for a popular franchise.
of the Candy Crush clichés with nothing new to
speak of, they’ve implemented absolutely nothing

Verdict// that made Cut the Rope successful or original. This is


shuffleware at its worst, and makes me wish I could
award this insult to Om Nom fans no stars at all! . JG
PROS AND CONS:
+ Om Nom’s there
- Nothing original
- Nothing interesting
- Nothing to do with Cut the
Rope
LAST WORD
This is Cut the Rope in
name only. Underneath
the veneer of a successful
franchise lies an
imagination-free match-
three game.
RATING: 1/5
The return of an unsung classic.

Info//
R
emember Mokoko, the awesome Mac unlock during the game. Complete the Story Mode to
game that drew its inspiration from arcade unlock Arcade Mode.
NAISU
classics such as Volfied, Qix and Gals Panic?
http://naisugames.com
Remember how you patrolled the perimeter of
£7.19, $9.99, 8.19 €
the gaming area, nibbling away at the central, Girls, girls, girls...
silhouetted area until you’d captured a given Another feature that’s retained from the original title
percentage of the screen? Remember how the is the optional adult patch that removes the clothes
enemies would maraud around, causing you to die if of the girls you reveal and rescue during the game.
they touched or shot your trail while you pressed on This time it’s free too. The gameplay is identical
into enemy territory? If you completed the game but to its predecessor, but if you’ve been reading this
would welcome more of the same, developer NAISU magazine for a while, you know that’s no bad thing.
has released a sequel; Mokoko X. Mokoko was, and is, great fun to play and this
The new game offers 32 levels in total, comprised reimagining is just as entertaining.
of 24 levels with unique bosses and minions, and If you’re a fan of old-school Qix-style games,
eight mega-levels where you fight three bosses from this one’s definitely worth a look. It’s excellent
the previous levels at the same time. There are eight value for the price. If you played the original and
different anime-influenced girls to rescue, Japanese are now bored of it, though, there’s nothing much
and English voice-overs and various power-ups to new here. AF

Verdict//
PROS AND CONS:
+ Lots of game for your
money
+ Colourful and attractive
+ Fun to play
- A little derivative?
LAST WORD
It makes no real advances
on the original Mokoko
game, but like its
predecessor, it’s a great
blast.
Capture territory to reveal the girl underneath it. Claim it all to rescue her. RATING: 4/5
Anomaly Warzone
Earth
A Tower Defence game that sets the genre on its head!

Info//
T
he tower defence game is a staple of the App during actual gameplay which adds a frantic level
Store. The real-time weapons placement of excitement to the battles. The inclusion of a basic
11bit studios s.a
and short gameplay bursts seem perfect for resource-gathering mechanic adds another level of
www.anomalythegame.com
a portable touchscreen device. While we’re big fans complexity. You must plot a course to capture items
£3.49, $3.99, 3,99 €
of this genre, we’ve found ourselves getting a little that are used to upgrade your forces.
tired of the predictable gameplay. The setting and The game has three modes of play, with an
plot may change, but the concept of defending engaging Story Mode and two Squad Assault
your base using various static weapons from waves Modes. The visuals and sound are fantastic, and
of approaching enemies has remained the same. the whole thing is wrapped up in an impressive
However, just as fatigue appeared to have set in, presentation shell. The only real downer is the lack
Anomaly Warzone Earth has blasted onto iOS and of a multiplayer mode, but even without it Anomaly
iPadOS and flipped the tower defence genre on its Warzone Earth is a highly recommended game. JG
head. This time you take control of the attacking
craft as they battle through the landscape, avoiding
or destroying the enemy’s defences.

Role reversal
This role reversal is the key to the huge success
of the game. The conventions of the gameplay,
although refreshed, remain familiar. Plot your path
through the stage by consulting the map screen,
and choose your convoy of vehicles with great
care. As before, the wrong choice quickly ends your
game. Unlike its many predecessors, upgrades
and enhancements can be employed in real time

Verdict//
PROS AND CONS:
+ Refreshing gameplay
+ Deep strategies
+ Top aesthetics
- No multiplayer
LAST WORD
A new look at an old
game style, and a very
successful one too. Highly
recommended.
RATING: 4/5 Tower offence – instead of placing the towers, you play the attackers.
Keeping it (looking) real, 1990s style!

Info//
P
art game, part interactive movie, when the game its unique atmosphere and it still stands up
Another World was first released for the Amiga even in its original form.
DotEmu
it was more than just another game. It was a The usual control issues are present,
www.dotemu.com
real interactive experience. Rather than falling into unfortunately, but they’re quickly dispatched by
£3.49, $3.99, 3,99 €
one of the established genres of the time, Another using a compatible controller, if you have one.
World was neither a puzzle game, a shoot-’em-up Developers still haven’t figured out a way to
nor a platformer, but it was all of these and more. perfectly recreate micro-switched joystick controls
Playing it now it’s easy to forget how using a touchscreen. This can make sections where
revolutionary it was at the time. The spookily precise positioning and timing are required harder
realistic sprite animation still looks very nice, but it than they ought to be, and you need plenty of do-
was gob-smacking in 1991. The game begins with a overs for this reason.
scientific experiment gone wrong, which transports If you didn’t experience Another World in its
the main character to a strange, dream-like world original format, it’s still a great little game but you
and so begins the adventure where you take on won’t understand quite how fantastic and ground-
challenge after challenge as you try to stay alive breaking it actually was. If you did have the pleasure
and figure out a way to get back home. You even of playing through it back in the day, you’ll relish the
make a friend along the way, and despite the lack opportunity to relive it in all its glory. The slightly
of dialogue, the game manages to conjure a real choppy controls only marginally mar this bona-fide
emotional connection between the two characters. all time classic. JG

Thirty Years On...


The mobile version comes with polished, enhanced
graphics, but with the option to switch back to
the original style. The enhanced version doesn’t
change the overall look, but adds some depth to
the backgrounds, which is a good thing. Although
the highly stylised nature of the visuals has much to
do with the limitations of the original hardware for
which it was designed, this is all part of what gives

Verdict//
PROS AND CONS:
+ Classic game
+ Excellent animation
+ Outstanding atmosphere
- Control issues
LAST WORD
A genuine classic that
stands up very well
compared to modern
games. A welcome blast
from the past.
Switch between retro and HD graphics. RATING: 5/5
Grand Theft Auto:
Chinatown Wars
The most underrated handheld title of its generation finds its true home!

Info//
M
ajor franchises tend to have an instalment modified specifically for the iPhone/iPad screen,
that fans consider a misstep. A few (un) visually Chinatown Wars has never looked better
Rockstar Games
popular examples; Star Trek 5: The Final and more unique.
www.rockstargames.com/
Frontier, Super Mario Sunshine, Tomb Raider: Angel
chinatownwars
of Darkness, any Star Wars movies that don’t have
£4.49, $4.99, 4,99 €
Part 4, 5 or 6 in the subtitle... The list is endless Turn On, Tune In...
and, of course, 100% personal. But what about A nice feature added into this version is the ability
those games or movies that were largely ignored or to pick from five different radio stations combining
disdained despite being not bad at all? 100+ minutes of in-game music. Alternatively, you
With that in mind, let’s head back to Liberty can listen to your own music library from within
City, albeit in a way you’ve never seen before, or the game by using iTunes to create a playlist and,
again. Launching with very little fanfare in 2009, calling it “GTA”, then syncing your device to upload
Grand Theft Auto: Chinatown Wars was the first it. When it’s uploaded, start the game and select
original instalment in the monster franchise the Independence FM radio station to listen to
developed with the handheld market in mind. your own tunes.
Retaining the core of the current 3D console You control Huang Lee and start off with a
counterparts, it played out as action-adventure simple mission; deliver a sword to his Uncle Kenny
game set in an open world environment. as part of a Triad legacy for control. But it doesn’t
The visual presentation – due to hardware go well. It’s time to regain your honour and get
limitations of its host machine, the Nintendo DS revenge for what happened to you by using all
– opted for an isometric top-down camera over the usual methods found in the GTA titles. There’s
of a ground-level view behind the protagonist, some excellent gameplay tweaks I feel should’ve
reminiscent of the early 2D Grand Theft Auto titles. transferred to the main series, such as the ability to
This disappointed many at the time, and resulted remove those pesky wanted levels by destroying
in unjust criticism that has hampered this release the chasing police vehicles, not having to outrace
since. GTA: CTW provides a fantastic reproduction them or hit up a Pay and Spray! A differing
of the familiar gameplay style keeping within the mechanic for ‘borrowing’ a moving vehicle and a
confines of the original development platform. parked one is another nice inclusion.
With this mobile port, those limitations have If you haven't played this wrongly overlooked
been removed but by using some very clever instalment of the GTA franchise before, I would
touchscreen functions, including two custom suggest you try it on the iPhone instead of a retro
control settings depending on your preference, handheld. Chinatown Wars offers a unique view of
this port has taken an already stunning game and the popular series, perfectly bridging a gap between
made it even better. With enhanced graphics, its origins and its more contemporary releases. And

Verdict// lighting and explosion effects that have been is absolutely due for a rediscovery for all gamers. JG

PROS AND CONS:


+ New take on GTA
+ Interesting storyline
+ Good gameplay
mechanics
+ Excellent radio options
LAST WORD
A game that deserves to
be better regarded than it
actually is. Give it a go and
see if you agree.
RATING: 4/5 The top-down perspective is similar to that of the early PSX Grand Theft Auto games.
Welcome to a world of sword, sorcery and interactive video clips.

Info//
A
s a retro gamer I love the fact that Apple’s to aid you in your journey and it can get tricky and
mobile gear is creating a new platform frustrating as you try to figure out the right move
Dragon’s Lair LLC
for classic games, and Dragon’s Lair 30th and the perfect timing. The game really relies on
www.digitalleisure.com
Anniversary (a subtitle which I will now ignore as it getting just the right timing so you might have the
£4.49, $4.99, 4,99 €
essentially screaming “YOU ARE SO OLD” in my face!) right move but at the wrong second; don’t give up
is one of the best to join this trend. In the arcades, the too quickly.
game used a laser disc at the core of its technology.
You had to press the joystick or the button at the
correct time to cause the disc to skip to the next Cartoon Capers
section. Press the wrong direction or take too long The repetitive scenes might start to get on your
and the disc skipped to one of the many comic-book nerves, and I know I got a little annoyed if I got stuck
death sequences. This version of the game is just on a section and had to replay the same scene over
like the original, but with all the crisp, hand-drawn and over again. The graphics are great and really
animated graphics preloaded on your device. appeal to children because it looks and feels just
As I wasn’t the son of a multi-millionaire or able to like playing a cartoon, though younger children
magic coins from thin air, I never mastered the brutally might get frustrated trying to figure out the game.
hard arcade game, so I was thankful this version I was a little disappointed with the sound, though,
comes with a tutorial to teach you the controls and as it got repetitive and boring but it was not enough
explain the different game versions. For those looking to detract too much from the game. In the end this
for a challenge, I recommend playing around with game plays like a point-and-click adventure on
the options first because the game starts you off with steroids as you have to know just what to click and
the move guide which tells you what moves to make you have only seconds to figure out the right move
using the on-screen D-pad and weapon controls (but before poor Dirk is dead meat.
you have to act quick to get the right timing, so leaving After many attempts to bring this classic game
the guide on might be good for kids). to the attention of a new generation, Dragon’s Lair
The way the game works is that you (Dirk) are on the iOS is the first truly successful conversion that
presented with situations as you try to make your takes all the charm, quality animation, humour and
way through the castle to save your beloved. You hair-pulling fun of the arcade original and puts it in
have the four directional arrows and your sword the palm of your hands. JG

Verdict//
PROS AND CONS:
+ Great looking
+ Tutorial included
- Weak sound
- Repetitive
LAST WORD
A great conversion of the
coin-op, but it can be just
as frustrating as its arcade
inspiration at times.
Uncomplicated controls; just ‘up’, ‘down’, ‘left’, ‘right’ and ‘sword’. RATING: 3/5
/

Disco Elysium –
The Final Cut
You’re drunk, you’re hung over, and you’re – who am I again?

Info//
ZA/UM
https://discoelysium.com
£34.99, $39.99, 39,99 €

W
ow, that was some night. Or at least you To begin with, you choose an ‘archetype’ for your
think it was. You’re dirty, (almost) naked booze-impaired detective. At your choice, he can
and your head is pounding, but you can’t be a Thinker, Sensitive or Physical being, each of
remember the drinking session that caused your which assigns the skill points with which you start
predicament. In fact, you can’t remember much of to different qualities your character possesses. As
anything at all. Who are you? What are you doing you progress through the game, you level up and
here? Why is there a dead body hanging from a tree are given more skill points to allocate as you see fit.
around the back of the flea-pit hostel you currently There’s also the option to create your own character
reside in? These are the questions you must answer as from scratch, though we wouldn’t recommend
you solve the murder, and also sort out your personal this on your first play-through. Starting with a new
issues as you go. personality and statistics for your character gives the
Disco Elysium is a fusion of point-and-click game replay value for when you’ve completed its 30+
adventuring and RPG-style character building. hours the first time.

Much of the game takes place in your


head, as you have multiple-choice
conversations with various sectors of
your brain. First sign of madness?
View to a Thrill...
The game is viewed from a 3D isometric view. You
move around by clicking your mouse or trackpad
on a piece of the floor, which your character
then walks to. you can also click nearby objects
and items of interest. Things with which you can
interact are identified by a white spot, and holding
the Tab button highlights everything you can
click on, whether for information or to pick up
and add to your inventory. If you hate adventures
where you have to constantly drag your pointer
over the screen searching for interactive items,
you’ve nothing to fear here. You can zoom in and
out of the action if you want a closer look or a
wider viewing area, but we wish you could also
push-scroll around the current location instead of
having to move the character to see what’s beyond
the screen area.
Being a detective story, much of the gameplay
involves multiple choice conversations, not only also what you’re wearing. A detective’s hat might Objects of interest are identified
by a white dot, and hold Tab to
with non-player characters but also within your make you smarter, for example, and a gang jacket highlight everything with which you
own head. There are 24 sections of your brain could make you more intimidating. Keep collecting can interact.
with which you can chat, communicating as if the clothes and change into something more
they were themselves third-party characters. appropriate if an important roll is coming.
Which parts of your brain have something to say
and what advice they give depends on the type
of character you chose and what skills you’ve
Other stats to keep an eye on are your health
and morale. If they reach zero, you’re in imminent
danger of dying or giving up respectively. You can
Verdict//
PROS AND CONS:
acquired since. It sounds bizarre, and it is, but it’s a pick up items that restore a few points of either;
+ A very original idea
fantastic and original gameplay mechanic the likes in that respect, the game’s more like an RPG. Just
of which we’ve never seen before. remember to save often and not rely on your Auto + Brilliantly atmospheric
Saves, as it’s entirely possible to die in this game.
+ Good replay value
Aesthetically, Disco Elysium is beyond reproach.
In the Balance It’s wonderfully atmospheric, and gives you a real - We wish you could push-
The game offers a good balance between adventure feeling of being there. The hand-painted graphics scroll
and RPG, though it leans more to the adventure are beautifully realised, and the voice-overs
LAST WORD
side. The odd punch aside, there’s no combat (expanded for this Final Cut release) are almost
An excellent update for an
to speak of. There’s no bruising encounters with impeccable. As your character awakens from his
amazing adventure RPG. If
section bosses, and no tedious grinding out fights booze-induced slumber, you almost ache with him.
you missed Disco Elysium
with lesser foes to build your stats ready for the Even when you frustratingly die or have a meltdown
before, don’t make the
next big baddie. It has more variables than a long after you last saved, you feel compelled to give
same mistake again.
regular adventure, though. Some actions demand a it one more go. It’s exciting, atmospheric, intelligent
successful dice roll to determine success or failure, and above all, original. If you like your RPGs, don’t RATING: 5/5
with your target score influenced by your stats and miss this genuine gem of a game. IO
Minion Rush:
Running Game
The adorable Minions are back on the big screen, but is their
iOS licensing going to be despicable?

Info//
Gameloft
https://www.gameloft.com
Free (IAP)

It looks great, but mind it doesn’t grate.

I
f you’re a fan of the Despicable Me/Minions Up to jump over obstacles, and swipe Down to slide
movies, and also enjoy endless runners, you’ll love under laser beams and such.
this. You play as one of the cute little minions from The game offers a few surprises that help
the movies, trying to become Employee of the Month distinguish Minion Rush from almost every other
by running as far as you possibly can. It’s not clear endless runner. For starters, the graphics are
what the purpose of the run is, but unlike every other fantastic! Secondly, the game doesn’t offer a
endless runner game, there is a storyline of sorts. straight, simple dash. Instead, the camera angle
Gameplay uses a three-lane system with swipes changes regularly, sometimes forcing you to adjust
in four directions. As your minion charges forward, to a side view of the track in order to succeed.
simply swipe Left or Right to dodge objects and Switching views is seamless and doesn’t interrupt
avoid falling employees, cliffs and more. You swipe your run whatsoever.
Slide it in!
There are also sliding segments in which you
control your minion by tilting your Apple device
from left to right, which is a nice change of pace.
There are even boss battles to contend with. Every
now and then, Gru’s rivals appear and launch
As endless runners go, this one’s top banana.
smaller robots at you, which you must tap quickly
to reflect them back at him. Additionally, there are
bananas scattered all over the place, which act
as the game’s main currency. There are several
types of power-ups that appear too, and each
Verdict//
PROS AND CONS:
one can be upgraded by spending Bananas. The
+ Great visuals & sonics
second type of currency is Tokens, which appear a
maximum of five times per day. + Who doesn’t love Minions
Just as in Temple Run, the key to success is
+ Nice gameplay variety
building up your multiplier, which is done by
performing Despicable Acts. These usually involve - Grinding vs In-App
running into or otherwise displacing your fellow Purchases
minions, but you can also earn this bonus by
LAST WORD
wrecking things using your power-ups.
Even if you strip away the
You can unlock new bonuses, which actually
trademark visuals and
act like new characters, as each new bonus offers
excellent presentation and
you new abilities, skills and items. Some can be
you still have a way above
purchased using Bananas, but the majority of
average endless runner.
them require the rare Tokens, and a lot of them!
Top Bah-Nan-Ah!
You can speed up the process by buying Token
bundles via IAP, although grinding hard is where RATING: 4/5
you find yourself in most of the game. JG
LEGO Star Wars: TCS
Does anyone really care about the Star Wars movies or the LEGO games
anymore? Maybe a long time ago they did?

Info//
Warner Bros. Entertainment
https://videogames.lego.com
Free (IAP)

A
long time ago, on a console far, far away a proton torpedo in a thermal exhaust port.
(probably in the attic?), the LEGO Star Wars LEGO Star Wars: The Complete Saga (although
saga was unleashed. Despite having a bad it clearly isn’t complete as it misses the recent
feeling about it due to the child-friendly visuals, trilogy) couples the 2005 prequels with 2006’s
the comedic leanings of the cut scenes and the original trilogy. Both titles are remastered for the
general sense of this being a ‘kid’s game’, it proved iOS platforms, yet while both incarnations of the
to be absolutely fantastic. It reached across age games are superior to their predecessors in every
demographics by delivering an experience that way, somehow as a whole this package is less
was accessible enough for younger players but impressive than a duo of games almost as long in
challenging enough for the more mature gamer. the tooth as our editor.
Plus the seemingly endless self-referential nods to The game spans all six instalments. The
the fan base were whoop-inducingly brilliant. All cutesy LEGO style and humour still hooks, but the
bases were covered. gameplay formula which has remained somewhat
This was not only the Star Wars prequels in Lego unchanged not only over this franchise but the
form, but unlike their big-screen counterparts, it was series as whole just feels uninspiring, overly
fun and a pleasure to immerse yourself in. The games- familiar even bordering on dull. Once again the
buying public agreed, and the Traveler’s Tales/LEGO narrative is themed around the movies, with each
gaming franchise became a monster, pulling in such level covering the key plot points of the source
marquee names as Pirates of the Caribbean, Indiana material. On your first time around each episode
Jones, Harry Potter, Batman, Marvel, DC and Lord of is played in order, completing one to unlock the
the Rings. Yet was The Force as strong with this series next. Progression is, as always with the LEGO
as one would expect? franchise, based around completing objectives
such as item collection, block building, puzzle
solving and some basic combat.
Brick by Brick Once you've completed all the games, you can
With this rerelease for iOS, we’re back to the revisit each level randomly to seek out the secrets
franchise that launched a thousand polygon and hidden items which you might have missed
Help Leia escape in this epic bricks; LEGO Star Wars: The Complete Saga. Sadly, or simply weren't able to collect with your default
scene from  2 *+ . from even the briefest of plays, it’s very clear the characters and their abilities. While we are the first
bottom of the barrel is being scraped deeper than to complain when the tactic of back-tracking over
“Hokey religions and ancient weapons are no match for a good blaster at your side, kid.”

a worn path is employed to extend lifespan, the that these are first instalments in the series. The
second trip through is actually more fun, offering a gameplay, presentation and control have been
greater challenge. honed for this platform, but while we weren’t overly
During your first play-through you’re teased by impressed with this game, we did enjoy moments,
items that are just out of reach with your starting we can't ignore the creeping sensation that the
character, or tiny doors that beg to be opened LEGO games had hit a plateau, a long time ago.
if you were small enough to do so. There lies
the appeal of replaying each stage; by switching
appropriately among the full cast of characters Milking the Cash Cow
unlocked during your first run, no path is blocked, There’s no question these early Star Wars games
no secret cannot be uncovered. It would be a are some of the best of the LEGO series, but that
stretch to say the gameplay is reinvented for your series is simply stale. Therein lies the quandary that
second trip but the motivation is certainly enough gamers face, with not just this release but the series
to pay this game another visit. in general. How often can a franchise be rehashed,
re-worked and tweaked before what was once
clever and original becomes cliché? In our opinion
Taking Control the series has reached its zenith, and should
While a rehashing of the console game could have
been the easy path for the developers to take,
instead this version was built specifically for the iOS
probably be rebooted. We were left feeling that
without additional development and some much-
needed innovation this could be the last golden
Verdict//
PROS AND CONS:
platform. If features a fantastic control method which brick on the LEGO game pile before over-familiarity
+ Great visuals & sonics
uses both virtual sticks and screen taps, and is a causes its inevitable demise.
testament to how much effort has gone into making To sum up the experience of playing LEGO + Captures the Star Wars
this an exclusive iPad or iPhone game not a cheap Star Wars: The Complete Saga, the perfect word is feel
console port. While the control method is inventive, ‘contradiction’. The game is great and still entertains,
+ Nice gameplay variety
the core gameplay and graphics follow the expected it holds the interest and we played until everything
LEGO template and offer few surprises. had been unlocked and collected. Unfortunately, - Missing three movies!
The visual familiarity of both the LEGO and once the game was over, it was almost instantly
LAST WORD
Star Wars franchises is in equal part a blessing forgotten amongst the blur of all the countless other
A package of two old and
and a curse. If you’re a fan of either, you need LEGO games we've played. Unfortunately these
tired games for a non-
no motivation beyond the title to download it. factors make for an experience that is forgettable and
budget price? Buy this, do
However, non-fans will find little motivation to even leaves you with the sense of how far the franchise
not. The developers didn’t
try the game. With the LEGO game franchise taking has fallen. Also, how can it be ‘The Complete Saga’
apparently try!
on every major movie series from Potter to Pirates when there are three (awful) movies and one game
over the past 17 years, it’s starting to look and feel completely missing? Come on, LEGO, do the magic RATING: 2/5
a very tired, even more so when one considers hand thing again. Please!. JG
঒ন঻ষ঍শশসন
Come back next issue for even more fantastic
copy from our team of experienced industry
insiders. We will be covering all the latest
software advancements, consumer tech and
expert tutorials that you can expect from us.
঺঺঺ॲ঳দয঳সথযবদতষবল঱শॲদলর
On Sale September 2023 via digital platforms
Get Your Exclusive
FREE Gift Worth
£9.99 Here!
Download
Your FREE
Copy of
Tech Shopper
Magazine
Head over to your web
browser and follow these
simple instructions...

1/ Enter the following URL: www.pclpublications.com/exclusives


2/ Sign up/in and from the listings of our exclusive customer
downloads, highlight the Tech Shopper Magazine option.
3/ Enter your unique download code (Listed below) in the “Enter
download code” bar.
4/ Click the Download Now! Button and your file will automatically
download.
5/ Your file is a high resolution PDF file, which is compatible with
the majority of customer devices/platforms.

Exclusive Download Code: PCL37862RE


NOTE: This is a limited reader offer running from 1st January 2023 to 1st September 2023.
Terms and conditions apply and can be found at www.pclpublications.com
Don’t miss out on more great
magazines
on digital platforms now!

www.pclpublications.com

  )>97<;8?;0?=3>?9>2<9>5?3:95*:9>(? =?9>.:<87?=3>?12943:7>97?7;6> "3<7?$:1>942=?%<.<=>5?12-6<4:=<;8?<7?0266/?<85>1>85>8=?:85?:7?7243


9>71;87<-<6<=/?=;?5>=>9.<8>?=3>?72<=:-<6<=/?;0?=3<7?-;;'?:85?<=7?4;8=>8= 5;>7?8;=?8>4>77:9<6/?9>06>4=?=3>?)<>*7?;9?;1<8<;87?;0?=3>?19;524>97?;0
     
0;9?*3:=>)>9?1291;7>(?&8/?<.:,>7?9>19;524>5?;8?=3>?09;8=?4;)>9?:9> &117?;9?19;524=7?4;8=:<8>5?*<=3<8(?"3<7?12-6<4:=<;8?<7?8;=?>85;97>5?;9
$2-6<73>5?-/ $:1>942=?%<.<=>5 7;6>6/?0;9?5>7<,8?1291;7>7?:85?:9>?8;=?9>19>7>8=:=<)>?;0?4;8=>8=(? :77;4<:=>5?<8?:8/?*:/?*<=3? :8;8<4:6?%=5+?$/=3;8+?"3>?%<82
#:8:,<8,?5<=;9 :.>7?:6> >?:5)<7>?:66?1;=>8=<:6?-2/>97?=;?43>4'?6<7=<8,?19<;9?=;?12943:7>?0;9 ;285:=<;8+?"3>? :71->99/?$<?;285:=<;8+?& #?;65<8,+?>-<:8?$9;>4=+
$9;524=<;8?<9>4=;9 #:9'?&/730;95? 4;80<9.:=<;8?;0?:4=2:6?4;8=>8=(?&66?>5<=;9<:6?;1<8<;8?3>9><8?<7?=3:=?;0?=3> %<82?#<8=+?#<49;7;0=+?%>8;);+?>66+?>*6>==$:4':95+?&116>?:85
5<=;9 :.>7?:6> *9<=>9?:7?:8?<85<)<52:6?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9.:=<;8?>.:<6?,:6>14612-6<4:=<;87(4;.

You might also like