If-Else Statement — Make a Win Condition

We have a cube. Each time we press the space, we want to add 10 points to a total. When it hits 50, you win and it turns the cube green.

To do this, let’s start by setting up the variables necessary for the score condition, our object, and our renderer.

Next, we want to get the component of renderer inside of our object.

Finally, let’s do a simple update method that adds 10 points per space press. If our current score is greater than our grandTotal, let’s change the color of our cube and show our win condition.

--

--

--

Unity Developer and Software Engineer who loves making games with GameDevHQ

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Type-safe lazy loading of non-routed modules and components in Angular

Material UI in React #3 — Styles — adding global theme and overriding default styles

React/Redux Integration Tests with Jest & Enzyme

ES8 Feature Set: JavaScript is Getting Asynchronous

7 Tricks to Write CSS Code in One Line!

Writing fewer CSS code

INTERMEDIATE JAVASCRIPT

Specialized Subjects in RxJS

Introduction to React. Js

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Al Heck

Al Heck

Unity Developer and Software Engineer who loves making games with GameDevHQ

More from Medium

Persia DAO: A project that reminds of Cyrus The Great!

UNI announces ‘Edutrain’ — Architecture Competition to Design a Care & Learning Center for street…

Fighting to Win: How an Indonesian Land Defender Stood up to Conflict Palm Oil

Unit Testing for Powerplay