{"id":23553092,"url":"https://github.com/rhildred/droidfoot","last_synced_at":"2025-07-11T08:03:48.824Z","repository":{"id":146396815,"uuid":"49398259","full_name":"rhildred/droidfoot","owner":"rhildred","description":"droidfoot makes it possible to run greenfoot scenarios on Android","archived":false,"fork":false,"pushed_at":"2016-01-27T17:19:59.000Z","size":4911,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"gh-pages","last_synced_at":"2025-02-17T12:45:21.340Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://www.programmierkurs-java.de/droidfoot/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rhildred.png","metadata":{"files":{"readme":"README.md","changelog":"changes.txt","contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-11T02:55:52.000Z","updated_at":"2021-08-27T17:53:16.000Z","dependencies_parsed_at":"2023-04-21T19:07:59.347Z","dependency_job_id":null,"html_url":"https://github.com/rhildred/droidfoot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhildred%2Fdroidfoot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhildred%2Fdroidfoot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhildred%2Fdroidfoot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhildred%2Fdroidfoot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rhildred","download_url":"https://codeload.github.com/rhildred/droidfoot/tar.gz/refs/heads/gh-pages","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254388003,"owners_count":22062965,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-26T11:14:01.031Z","updated_at":"2025-05-15T17:30:21.738Z","avatar_url":"https://github.com/rhildred.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# droidfoot\n\nThis is a project by Dr. Dietrich Boles to allow greenfoot scenarios to run on Android. I made some minor changes for the project to run on Android Studio and with Dr. Boles kind permission am publishing my changes on github.\n\n![Space Invaders](https://rhildred.github.io/courses/MB215/SpaceInvaders.png \"Space Invaders\")\n\nIn this article, I am getting [this space invaders clone](http://www.greenfoot.org/scenarios/15902) to run on Android. Getting a Greenfoot scenario onto Android has 3 basic parts:\n\n##In Greenfoot\n\n\u003ciframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/hbI0Irwx59o\" frameborder=\"0\" allowfullscreen\u003e\u003c/iframe\u003e\n\n1) While still in Greenfoot, change your java world file to use setBackground(\"cell.jpg\"); in the constructor to include its background image. This might also be a good time to make the size of your world to fit a phone:\n\n```\npublic Space()\n{    \n    // Create a new world with 240x400 cells with a cell size of 1x1 pixels.\n    super(240, 400, 1); \n    prepare();\n    setBackground(\"background.jpg\");\n}\n\n```\n2) Also, still within Greenfoot, change your java actor files to use setImage(\"leaf.gif\"); in the constructor to set the actor's image.\n\n```\npublic class Player extends Actor\n{\n    public Player(){\n        setImage(\"spaceship-icon.png\");\n    }\n\n```\n3) Test, to make sure that the world and actor classes still have images. (This is necessary,\nbecause only the java, image and sound files are going to be used in the droidfoot Android\nversion of the project.)\n\n4) Change the UI to be mouse based, rather than keyboard based:\n\n```\npublic void act() \n{\n    if(Greenfoot.isKeyDown(\"right\")){\n        move(4);\n    }\n    if(Greenfoot.isKeyDown(\"left\"))\n    {\n        move(-4);\n    }\n    if (shotTimer \u003e0){\n        shotTimer = shotTimer -2;\n\n    } else if(Greenfoot.isKeyDown(\"Space\"))\n    {\n        getWorld().addObject(new Ordnance(this),getX(),getY());\n        Greenfoot.playSound(\"pew_backup.wav\");\n        shotTimer = 68;\n    }\n}\n```\n\nIn my case, I substituted clicking on the ship for the space bar (shooting) and the ship moving to where you touch for the arrow keys.\n\n```\n\npublic void act() \n{\n    if(Greenfoot.mousePressed(this)){\n        getWorld().addObject(new Ordnance(this),getX(),getY());\n        Greenfoot.playSound(\"pew_backup.wav\");\n        shotTimer = 68;\n    }else if(Greenfoot.mousePressed(null)){\n        MouseInfo info = Greenfoot.getMouseInfo();\n        setLocation(info.getX(), getY());\n    }\n}\n\n``` \n\n5) Test your scenario to make sure that it is mouse driven.\n\n##In Android Studio\n\n\u003ciframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/tbWY_tOFpfY\" frameborder=\"0\" allowfullscreen\u003e\u003c/iframe\u003e\n\n1) Copy-paste the eclipse android project DFTemplate to a new eclipse project called Space Invaders (in this example).\n\n2) Open Android studio and import the new eclipse project (SpaceInvaders in this example) in to a new Android Studio Project. \nNote* You may need to edit dFTemplate/build.gradle and droidfoot/build.gradle to have the latest compileSDKVersion\n\n```\nandroid {\n    compileSdkVersion 23\n    buildToolsVersion \"23.0.2\"\n\n```\n\n3) Open the file strings.xml in folder DFTemplate/src/main/res/values and replace the name DFTemplate by the name of your scenario (e.g. Space Invaders).\n\n4) Rename the package org.droidfoot.dftemplate in folder src (e.g. org.droidfoot.spaceinvaders) (\u003eRefactor \u003e Rename).\n\n5) Rename the file/class DFTemplateActivity in folder src in the package being renamed in step 4 (bspw. SpaceInvadersActivity)\n\n6) Open the file AndroidManifest.xml and rename the package-attribute (second line) corresponding to the renaming in step 4 (e.g. package=\"org.droidfoot.spaceinvaders\" )\n\n7) Copy the java-files of your Greenfoot scenario into the package being renamed in step 4. Please note that you will have to edit all java-files to define the corresponding package-statement as the first statement (`package org.droidfoot.spaceinvaders;`).\n\n8) Eliminate all errors in your java-files which can occur due to the differences between the original and the Android Greenfoot class library (see chapter 2).\n\n9) Open the activity file being renamed in step 5, remove the comment in front the statement in method onCreate and assign the class object of your world class to the variable\nDroidfootActivity.worldClass (DroidfootActivity.worldClass = SpaceInvadersWorld.class;\n\n10) Copy the folders images and sounds which contain the images and sounds of your Greenfoot scenario into the folder DFTemplate/src/main/assets. If you have done this correctly, you will see the assets in android studio.\n\n##Making the package\n\n\u003ciframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/H5DNgH8O1Wg\" frameborder=\"0\" allowfullscreen\u003e\u003c/iframe\u003e\n\nFinally you will make the Android package. \n\n15. Make a signed apk by going to the build menu in Android Studio.\n16. Upload the apk, using google drive, and download it on to your phone.\n\nThese games may look a little bit crude, but with a little imagination, they can still be very fun.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frhildred%2Fdroidfoot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frhildred%2Fdroidfoot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frhildred%2Fdroidfoot/lists"}