Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
The MASH code that I edited wasn't working, so I wanted to start fresh from the original code, I was looking around on the forums and someone said to delete the contents of the workspace and open it back up again and it would default to the original code, but that doesn't seem to be the case, now I just open up to a blank workspace.
Hi, I am doing the MASH java course and have got to a code challenge where I have to name a class. I can't get it as whenever I put in what I feel is correct i.e. it doesn't work, any help will be appreciated.Thanks
Classes are assigned inside the tags. For this challenge, you're looking to set the div elements to the class "favorite_stuff". That will allow you to apply the same styling to both divs. I've included a demonstration, and hopefully you can apply it to your challenge.
I am having this same problem. I am entering the syntax correctly as above, but it keeps sending a bummer message and telling me that the class attribute on both div elements needs to be set to . I've tried entering the information in the same way as the example in the workspace, but it isn't working. Am I doing something wrong, or is there possibly a bug here?
I don't want to waste your time with boring stuff you don't need. So I've made sure my courses are clear, concise, to the point, and free of technical jargon. No rambling or repetition, just the essentials you need to succeed, explained in plain English.
I know learning to code can be tough. So I've carefully organized my courses into simple, bite-sized pieces to help you progress smoothly, one step at a time. I'll guide you through each step of the way so you won't feel overwhelmed.
I believe the best way to learn is by actually doing. That's why my courses teach you the essential theory and provide practical exercises. You'll be able to practice everything you learn and apply it to real-life situations.
My courses are designed to prepare you for real-world jobs and interviews. With in-depth, comprehensive courses packed with real-world examples and exercises, you'll be ready to take on any challenge that comes your way.
Whether you're looking to learn a new language or just brushing up on your skills, I've got you covered. I offer a wide variety of courses so you can pick and choose what's most relevant to you. Plus, I make sure my courses are fun and engaging so you won't get bored.
I've taught millions of people how to code and become professional software engineers through my YouTube channel and online courses. I'm humbled and thrilled to be a part of their programming journeys! When you join us, you're joining a group of like-minded people who are all working towards the same goal.
In the game MoleMash, a mole pops up at random positions on a playing field, and the player scores points by hitting the mole before it jumps away. This tutorial shows how to build MoleMash as an example of a simple game that uses animation.View the book chapter from the App Inventor Book by Wolber, et al. (Includes VIDEO tutorial)
Drag these components from the Palette onto the Viewer and assign their names. Put MyCanvas on top and set its dimensions to 300 pixels wide by 300 pixels high. Set the Text of ScoreLabel to "Score: ---". Set the Text of ResetButton to "Reset". Also add a Sound component and name it "Noise". You'll use Noise to make the phone vibrate when the mole is hit, similar to the way you made the kitty purr in HelloPurr.
You need to arrange for the mole to jump periodically, and you'll do this with the aid of a Clock component. The Clock component provides various operations dealing with time, like telling you what the date is. Here, you'll use the component as a timer that fires at regular internals. The firing interval is determined by the Clock 's TimerInterval property. Drag out a Clock component; it will go into the non-visible components area. Name it "MoleTimer". Set its TimeInterval to 500 milliseconds to make the mole move every half second. Make sure that TimerEnabled is checked.
Sprites are images that can move on the screen within a Canvas. Each sprite has a Speed and a Heading, and also an Interval that determines how often the sprite moves at its designated speed. Sprites can also detect when they are touched. In MoleMash, the mole has a speed zero, so it won't move by itself. Instead, you'll be setting the mole's position each time the timer fires. Drag an ImageSprite component onto the Viewer. You'll find this component in the Drawing and Animation category of the Palette. Place it within MyCanvas area. Set these properties for the Mole sprite:
You should see the x and y properties already filled in. They were determined by where you placed the mole when you dragged it onto MyCanvas. Go ahead and drag the mole some more. You should see x and y change. You should also see the mole on your connected phone, and the mole moving around on the phone as you drag it around in the Designer. You've now specified all the components. The Designer should look like this. Notice how Mole is indented under MyCanvas in the component structure list, indicating that the sprite is a sub-component of the canvas.
Now you'll specify the component behavior. This introduces some new App Inventor ideas. The first is the idea of a procedure. For an overview and explanation of procedures, check out the Procedures page.
A procedure is a sequence of statements that you can refer to all at once as single command. If you have a sequence that you need to use more than once in a program, you can define that as a procedure, and then you don't have to repeat the sequence each time you use it. Procedures in App Inventor can take arguments and return values. This tutorial covers only the simplest case: procedures that take no arguments and return no values.
With MoveMole done, the next step is to define a variable called score to hold the score (number of hits) and give it initial value 0. Also define a procedure UpdateScore that shows the score in ScoreLabel. The actual contents to be shown in ScoreLabel will be the text "Score: " joined to the value of score.
The next step is to make the mole keep moving. Here's where you'll use MoleTimer. Clock components have an event handler called when ... Timer that triggers repeatedly at a rate determined by the TimerInterval.
Scan the following barcode onto your phone to install and run the sample app.Download Source CodeIf you'd like to work with this sample in App Inventor, download the source code to your computer, then open App Inventor, click Projects, choose Import project (.aia) from my computer..., and select the source code you just downloaded.
Thank you for your help, and in terms of the hearts appearing in game and responding to when I miss (maybe disappearing after a miss), do I just need to add the images for the 3 individual hearts/lives onto the screen or do I need to add any new block commands for this to work properly. I Can show you the block commands I have in case you need it.
Yes, Three image controls in a horizontal layout, add image to Media. I used Androids instead of hearts This is not what you asked for but close. Adapt it to do exactly how you want touching any Mole to respond and also losing points when you miss.
scoringMole748652 102 KB
1.When mole sprite is missed, points are subtracted (I would like for it to not give or take any points when missed and only remove a heart when missing)
2.Game does not reset when all 3 hearts are lost
3. When Mole sprite is tapped successfully I regain lives (Would like for no hearts to be regained when successfully tapping the mole)
4.Also, I seem to not start off with any lives sometimes when I emulate the game (would like to always start with all 3 lives in the beginning or upon each reset)
5. Can you also confirm that the final green line all the way in the bottom of my code "Set ScoreLabel.text to get global score" is correct? (And maybe any other errors) Its not exactly the same name as what you have but it was the most similar one I could find, just wanted to make sure
1.When mole sprite is missed, points are subtracted (I would like for it to not give or take any points when missed and only remove a heart when missing)
2.Game does not reset when all 3 hearts are lost
3. When Mole sprite is tapped successfully I regain lives (Would like for no hearts to be regained when successfully tapping the mole)
And for point 3 that you didn't understand, If I had less than 3 hearts, I was regaining hearts back whenever I would successfully tap the mole. I didn't want hearts to be regained when tapping the mole successfully.
But now I'm not losing hearts when I miss the mole so I cant tell if that's still an issue.
You asked for and now have one way to handle a missing a mole tap. At the moment, I don't know what you expect to happen. Do you want the game to be playable up to three times, each time earning a heart or starting off with three hearts and subtracting a heart each time your clicking goal is not made. You don't want to subtract points so how do you expect this to happen? You probably need a Score variable and a separate numberOfHearts variable to keep track of mole clicks versus Hearts to display.
c80f0f1006