Rhys Streefland (Mentor)

Rhys Streefland (Mentor)

I am a Computer Science student at the University of Reading currently on my placement year with G-Research. I am a keen programmer and I'm especially interested in Android development.

Location London

Activity

  • You'll have to buy more than one to make it worth it :)

  • I'm still willing to help if you run in to difficulties. Just let me know :)

  • Have you seen the new $5 raspberry pi? I'll definitely be buying at least one...

  • It doesn't install on either of my devices Steve! It might be worth re-creating the apk file.

  • In order to select a player before the game starts you will probably need to create a new layout which is displayed before the main game layout is loaded.

    In order to save the mTotpl1 and mTotpl2 scores so that they exist when you close and re-open the app you'll need to save these scores to a file. When the app is opened, these scores need to be read from...

  • Why not try replacing the GameThread.java file with a fresh copy.

    If you post your GameThread.java on http://pastebin.com and post the link here I'll be able to point out what is causing the error.

  • That's a nice way to practice some java!

  • This is the link that you needed to share (just replace .git with .html):

    https://gist.github.com/Potisimus/90c9ceeed6416560f13d.html

  • This is just the log of the emulator loading. It's nothing to worry about.

  • This means that your device is out of RAM. Try closing some of the other applications that you are running on your device or just restart it. This app is not very big therefore it doesn't consume a lot of RAM when it's running, unless you have managed to introduce a memory leak into your code!

    If you could post your code on http://pastebin.com then post the...

  • Are you able to post your full TheGame.java class so I can try to run it to see what is causing the crash?

  • Very strange. Unfortunately I can't replicate this problem so I can't really help at the moment. I'll let you know if I work it out though!

  • No problem.

  • Dim problem o gwbl! Mae wedi bod yn bleser I mi helpu pawb. Dal ati :)

  • Great! Glad that's working for you.

  • Well done. Glad you managed to fix it.

  • What do you mean by 'have to use the default'. Can you provide me with a little more information about this error so I can help you?

  • The driver is installed with the Motorola Device Manager which you can obtain from here: https://motorola-global-portal.custhelp.com/app/answers/prod_detail/a_id/97326/p/30,6720,9050

  • Here you go Anthony: http://pastebin.com/Mtbd0viB

    You were trying to nest your repositionPaddle() method inside the updateGame() method. Methods are always need to be separate.

  • The line number is 255. Yes I'll take a look at that now.

    Here's the updateBallCollision() method for your reference: http://pastebin.com/iD6qmHaq

  • Glad you managed to fix it!

  • That is strange. Does touch input still work in your game when this happens? Or does the game stop working entirely?

  • I've taken a look. These warnings only exist because nothing depends on the mSmileyX and mSmileyY variables. You only ever set and modify their values, you never access their values (for use in a calculation for example).

    The compiler realises this and simply removes them from your code because they do not affect the program in any way at the moment. All...

  • No problem. That is a very strange issue indeed!

  • If you're still struggling, post your code on http://pastebin.com then post a link here then I can help you out.

  • It need to go inside your setupBeginning() method in TheGame.java, not in GameThread.java.

    //This is run before a new game (also after an old game)
    @Override
    public void setupBeginning() {

    //more code here

    mPaddle = Bitmap.createScaledBitmap(mPaddle, mCanvasWidth/5, mCanvasHeight/5, true);

    //more code here
    }

  • You need to use it to play sounds Joseph.

    Well done Steve!

  • I've upgraded and it works fine for me!

  • I would have liked to add network or bluetooth multiplayer but unfortunately I didn't have any time! I'll definitely add multi-device multiplayer to my next game.

    I had lots and lots of ideas of ways to improve the game but I had to be realistic as to what I could achieve in the time I was given. I think I'll save those ideas for my next game...

  • Does it effect the gameplay in any way?

    SensorManager: unregisterListener normally means that Android is turning the sensor off because it is no longer required by the app.

  • This usually means that you have set the value of a variable but it is never used again in your program (and thus is pointless).

    If you post your code on http://pastebin.com and post the link here then I can take a look and explain why it is occurring specifically in your case.

  • Are you able to post your code on http://pastebin.com then post the link here so I can take a look please?

  • Are you still having trouble John? There's still time for me to give you some help.

  • Try pressing Ctrl+F12 to change the screen orientation.

  • Your brackets were incorrect for the collision detection 'for' loops. You were nesting the two 'for' loops instead of keeping them separate which meant that the smiley ball collision detection code could never run.

    Take a look at the corrected code and see if you can spot where you've gone wrong:
    http://pastebin.com/w1EX5rnv

  • Unfortunately you can't! You need to create a drawable animation containing each frame of the animation: http://developer.android.com/guide/topics/graphics/drawable-animation.html

  • Try following these comments and implementing the code that I wrote for Kevin Draper here: https://www.futurelearn.com/courses/begin-programming/7/steps/42975/comments?page=1#comment_9016303

    If you run into any difficulty then let me know and I'll be happy to help!

  • Are you able to post some code so I can have a better idea of what you are trying to achieve?

  • Try following these comments and implementing the code that I wrote for Kevin Draper here: https://www.futurelearn.com/courses/begin-programming/7/steps/42975/comments?page=1#comment_9016303

    If you run into any difficulty then let me know and I'll be happy to help!

  • I just checked, and it is present in v6. Maybe re-download the game framework and take another look?

  • Did you manage to get it working? If not, then when you plug in your phone a message should pop up on your phone asking you if you want to allow this computer to access your device. You need to click allow in order to use your phone to run your game.

  • The error is in your AndroidManifest.xml file. Could you post the content of that file on https://pastebin.com and post the link here so I can take a look please?

  • That's not far off Malcolm! I'm going to use scaling the paddle as an example here but it's obviously also applicable to the other images in your game.

    You don't need to touch anything in TheGame(), just add the following line to setupBeginning() :

    mPaddle = Bitmap.createScaledBitmap(mPaddle, mCanvasWidth/5, mCanvasHeight/5, true);

    The reason that we...

  • If you get stuck just let me know and I'll be able to help.

  • Yes, using the debugger correctly can save a lot of time when trying to fix a bug!

  • What are you finding complicated? Maybe I can help!

  • I'm not quite sure what you're asking?

  • What don't you understand? Maybe I can help!

  • You're right, there doesn't seem to have been any activity for a while!

  • If anyone is looking for some inspiration in taking their game further, here's what I managed to come up with over the course of a few days:

    https://github.com/rstreefland/Block-Buster

    It uses the same game framework that you all used for this course and I wrote it as part of my coursework for my second year Java module last year. There are a few bugs...

  • It depends what you're looking to do really. If you just want to put some more time into your game to make it your own and add more features then you won't need to study much more Java. But if you decide to learn some of the core concepts of Java then you will eventually be able to write much better apps and also Java programs for the computer. Learning more...

  • In my opinion, the most interesting thing about writing a chess game would be writing a computer opponent AI.

  • Yes, the concepts learned in this course can be applied to programming other Android apps or even java programs.

  • I can imagine that these games employ a divide and conquer strategy by breaking the problem down into a number of simple(ish) algorithms that run in parallel and in turn increase or decrease the probability that the enemy has spotted the character.

    Interesting food for thought though!

  • It's often that the most simple Android games are the most successful!

  • Have you enabled developer mode on your phone? Have you allowed the installation of apps from unknown sources?

  • Glad you've got it working Artem.

  • Glad it worked for you, I enjoyed figuring it out. Now see if you can modify that code to load and play additional sound effects! (You only need to change/add a couple of lines of code)

  • You create a function like this:

    public void test() {
    //do something here
    }

    Then simply call your function like this whenever you want it to run:

    test();

  • Your missing some code in your updateBallCollision() method. Have another look the video/articles for this week.

  • The code that allows the score to be displayed on the screen is a little more complex and probably beyond the scope of the course to explain but you can easily access the value of the score variable by using the getScore() method (which exists in the GameThread.java class but is accessible from TheGame.java).

    You can also set the score by using the...

  • ...continued

    This line of code plays the sound:

    // play the sound effect
    sp.play(soundId, 1, 1, 1, 0, 1.0f);

    I've put it in the actionOnTouch method at the moment which means that it will play whenever the screen it touched (annoying I know). You can put this line of code anywhere to play the sound on a different event (e.g a collision...

  • Apologies for the time it's taken for me to get back to you with this one Kevin. I did see your pastebin but I didn't have time to do anything about it until today. I've never needed to use sound in an app before so I needed to learn how to use the SoundPool myself. SoundPool is a little bit of a nightmare because it is instantiated differently depending on...

  • Try using this driver: http://developer.samsung.com/technical-doc/view.do?v=T000000117

    Also, have you enabled developer mode and enabled USB debugging on your phone?

    Just create a new emulator in Android Studio and pick one of the ones with a smaller screen size/resolution.

  • Yes, a menu already exists in the framework but it can't be used with newer devices (devices that don't have a menu button or a menu softkey). If you want the menu to be available for these devices then you'll need to do the following:

    1. Remove this line from the AndroidManifest.xml file: android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

    2....

  • Take a look at the examples posted here which may be a bit easier to understand: http://stackoverflow.com/questions/14376807/how-to-read-write-string-from-a-file-in-android

  • Glad you managed to get it working!

  • Does your phone appear in Android Studio?

  • You could always try using the generic google drivers: http://developer.android.com/sdk/win-usb.html

  • Glad you managed to get that working.

  • Have you installed the driver on your computer? Have you enabled developer mode on your phone? Have you enabled USB debugging and allow apps from unknown sources on your phone?

  • Have you tried installing this Motorola device manager? (it contains the USB driver you require)

    https://motorola-global-portal.custhelp.com/app/answers/prod_detail/a_id/97326/p/30,6720,9050

  • Have you installed the HAXM emulator using the SDK manager?

  • You could try a third party emulator such as Genimotion which might give you better results.

    https://www.genymotion.com/#!/

  • Try using a new copy of the game framework. It looks like something is not right in your GameThread.java file.

  • If the game is working fine then I wouldn't worry about it. It's only a system debug message.

  • Have you tried using this driver? http://developer.android.com/sdk/win-usb.html

  • This is the intended behaviour at this point. If you uncomment the actionOnTouch() method you'll be able to bring the ball back onto the screen by tapping the screen.

  • What device do you have? Maybe I can help you find the correct driver.

    To improve the performance of the emulator, try reducing the screen size/resolution.

  • What are you trying to achieve? I can help.

  • You need to look in to using Bitmap.createScaledBitmap() which allows you to do this. If you provide mScreenWidth and mScreenHeight as arguments to this method then you'll be able to resize your image to any screen size. Just make sure to use a high resolution image otherwise it will appear pixelated on devices with a larger screen.

    Just let me know if you...

  • Steve is correct with his explanation of this behaviour. Feel free to have a play with the calculations to find out what works best for you though!

  • The best way to do this is to save the scores in a file and then load that file when the game is launched again. Have a read of the link below and let me know if there's anything you need a hand with.

    http://developer.android.com/training/basics/data-storage/files.html

  • The methods that you create in the TheGame.java class won't need the @override annotation. This is only needed if you are overriding a method that exists somewhere else in your program.

  • Not necessarily! The java compiler would almost certainly place the code of a function 'inline' during the optimisation of the code if the function is only likely to be invoked from one location in the code.

  • You are correct Tony.

  • That's the intended behaviour.

  • ...continued

    //Remove sadballs from screen if lose
    if(getScore()<= 0) {
    for (int i=0; i <= mSadBallX.length; i++) {
    mSadBallX[i] = -100;
    mSadBallY[i] = -100;
    }
    }

  • The most obvious change is that you done need four separate if statements for the below code:

    //Remove sadballs from screen if lose
    if(getScore()<= 0) {
    mSadBallX [3]= -100;
    mSadBallY[3] = -100;
    }
    if(getScore()<= 0) {
    mSadBallX[2] = -100;
    mSadBallY[2] = -100;
    }
    ...

  • I've just tried the v4 code and the score counter increments fine for me. Have you modified the code at all apart from the speed of the ball?

  • Put a /* before the actionWhenPhoneMoved() and a */ after it.

    By commenting out code you are effectively removing it from your program.

  • Why not comment out the actionWhenPhoneMoved() method and use only touch to control the paddle?

  • All you have to keep in mind with the curly brackets is; for every one you open you must also close it. As long as you do this then you will have no problems.

  • Try replacing all of the images in the res folder with a fresh copy.

  • Yes you're right! I'll be interested to see if you can achieve this :)

  • Are you able to post your code to http://pastebin.com and post a link here so I can take a look at that for you please?

  • Well done.