ZeroLuck wrote:
WindowsExplorer wrote:
I have an Android. I'll test it
Thanks.
Here is the first App:
game.apk
Can you tell me:
1. How it works.
2. How fast it is.
It works nicely although it took me a bit of time to figure out how it works. It runs pretty quickly. Its reasonably responsive as well. Btw, how does one exit the app? the usual back button does not work and it automatically shuts if i change the screen view by rotating my phone or pulling out the qwerty key pad. I'm using t on a sony ericsson xperia mini pro with android 2.3.3.
Must say I'm really excited
Offline
adityasm9 wrote:
ZeroLuck wrote:
WindowsExplorer wrote:
I have an Android. I'll test it
Thanks.
Here is the first App:
game.apk
Can you tell me:
1. How it works.
2. How fast it is.It works nicely although it took me a bit of time to figure out how it works. It runs pretty quickly. Its reasonably responsive as well. Btw, how does one exit the app? the usual back button does not work and it automatically shuts if i change the screen view by rotating my phone or pulling out the qwerty key pad. I'm using t on a sony ericsson xperia mini pro with android 2.3.3.
Must say I'm really excited
Soo... Could you convert my scratch game to apk?
Offline
ZeroLuck wrote:
Hey.
Here is an alpha version: ( You can't open your own files yet )
http://zero-bgn.de/player.apk
http://zero-bgn.de/playerscreenshot.png
Please tell me what you think about it!
I've got the EXACT same tablet as that!!! Also, yours is low charge
Offline
adityasm9 wrote:
It works nicely although it took me a bit of time to figure out how it works. It runs pretty quickly. Its reasonably responsive as well. Btw, how does one exit the app? the usual back button does not work and it automatically shuts if i change the screen view by rotating my phone or pulling out the qwerty key pad. I'm using t on a sony ericsson xperia mini pro with android 2.3.3.
Must say I'm really excited
I deactivated the back button but if you click on the home button (the house button)
the app will close! I know the problem that the app is closing when you rotate the screen. I will make a update for it...
I am very happy that it works so well on your Android!
Thanks!
WindowsExplorer wrote:
Coool!
1. It works great! Click and hold and the rocket goes to your mouse (or for me, finger tongue )
2. Pretty fast smile I'm guessing around 25 - 45 FPS!
[...]
EDIT: BTW, I'm running on an Archos 70 Internet Tablet with Andriod 2.2 (I think)
Thanks!
WindowsExplorer wrote:
How did you make it?
The app is programmed in Java,
and the Scratch project in Scratch
WindowsExplorer wrote:
Soo... Could you convert my scratch game to apk?
In the moment are not all blocks supported and there are a lot of glitches...
But I hope I will get the first stable version in some days/weeks.
(Because the player isn't based on something and I have to recode it.
And programming a Scratch player is very very much more work than a small Phyton mesh server )
But you will be the first who will get his scratch game converted to a apk!
EDIT
Lol, this topic has exactly 666 views
Last edited by ZeroLuck (2011-12-27 06:12:59)
Offline
Offline
Cool! Also, I can still test them by viewing them on the Scratch website on my Andriod with Flash
Offline
ZeroLuck wrote:
WindowsExplorer wrote:
Cool! Also, I can still test them by viewing them on the Scratch website on my Andriod with Flash
But this works not very well, or?
I tested it on my Android and the control was terrible
I will try to help more, because I really like the idea of Scratch on Android
To start, we need to test bigger projects, and controls. Here's a project I made for this project: http://scratch.mit.edu/projects/WindowsExplorer/2244023
Offline
Offline
WindowsExplorer wrote:
I will try to help more, because I really like the idea of Scratch on Android
To start, we need to test bigger projects, and controls. Here's a project I made for this project: http://scratch.mit.edu/projects/WindowsExplorer/2244023
Thanks!
I am very happy that you are interested to help me.
This player is very much work for me and I don't want to do it alone
Can you program in Java?
GP1 wrote:
The game runs, but is slow. However, I don't know how fast it is supposed to go. Great job, though (tested on Pandigital tablet 7" w/ Android firmware big_smile )
I know on some devices the app is slow:
It uses native Threads for every running Scratch hat block!
But because this works really well on the most devices am I not sure
to make a faster version with some changes for other devices, which can't handle Multithreading so good.
I think the most Tablets will have the right Performance in the near future!
adityasm9 wrote:
I'm willing to help any way i can
Thanks!
Can you program in Java?
Because this would be a great help!
But if you test the app and make some test projects it will be great too!
Last edited by ZeroLuck (2011-12-29 05:38:42)
Offline
Do you think you could post a small extract from the code, showing how you have implemented certain blocks? That way I (and others) could see how it works.
Offline
rookwood101 wrote:
Do you think you could post a small extract from the code, showing how you have implemented certain blocks? That way I (and others) could see how it works.
What blocks do you want to see?
I have implemented very much already
Offline
ZeroLuck wrote:
rookwood101 wrote:
Do you think you could post a small extract from the code, showing how you have implemented certain blocks? That way I (and others) could see how it works.
What blocks do you want to see?
I have implemented very much already
Hmm how about a hat block and how the hat block is linked with other stuff. Maybe a command block to see how they interact with the rest of the program?
Offline
rookwood101 wrote:
ZeroLuck wrote:
rookwood101 wrote:
Do you think you could post a small extract from the code, showing how you have implemented certain blocks? That way I (and others) could see how it works.
What blocks do you want to see?
I have implemented very much alreadyHmm how about a hat block and how the hat block is linked with other stuff. Maybe a command block to see how they interact with the rest of the program?
This class is for executing hat blocks:
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; public class ScriptExecuter { private static String HAT_MOUSE_CLICK_EVENT = "Scratch-MouseClickEvent"; private ScriptExecuter() { } public static void stopAllHats(ScratchPlayer p) { for (Thread t : p.hats) { t.stop(); } } public static boolean isNumber(Object o) { try { Integer.valueOf(toStr(o)); return true; } catch (NumberFormatException ex1) { try { Double.valueOf(toStr(o)); return true; } catch (NumberFormatException ex2) { return false; } } } public static boolean toBoolean(Object o) { if (o == null) { return false; } return o.toString().equalsIgnoreCase("true"); } public static String toStr(Object o) { if (o == null) { return ""; } return o.toString(); } public static int toInt(Object o) { if (o == null) { return 0; } try { return Double.valueOf(o.toString()).intValue(); } catch (NumberFormatException ex) { return 0; } } public static double toDouble(Object o) { if (o == null) { return 0; } try { return Double.valueOf(o.toString()); } catch (NumberFormatException ex) { return 0; } } public static Color toColor(Object o) { if (o == null) { return new Color(0, 0, 0, 255); } if (o instanceof Color) { return (Color) o; } return new Color(toInt(o)); } /** * May return null */ public static Sound toSound(Sprite sprt, Object o) { if (o == null) { return null; } if (o instanceof Sound) { return (Sound) o; } String n = toStr(o); for (Sound s : sprt.sounds) { if (s.getName().equals(n)) { return s; } } return null; } public static int toJavaX(Object o) { return toInt(o) + 240; } public static int toJavaY(Object o) { return -toInt(o) + 180; } public static void startOnClickHats(ScratchPlayer p, Sprite s) { for (EventHatThread t : p.hats) { if (t.msg.equals(HAT_MOUSE_CLICK_EVENT) && t.owner == s) { t.interrupt(); } } hat(p, HAT_MOUSE_CLICK_EVENT, s); } private static ArrayList<Thread> hat(final ScratchPlayer p, String msg) { ArrayList<Thread> started = new ArrayList<Thread>(); started.addAll(hat(p, msg, p.stage)); for (Drawable d : p.drawables) { if (d instanceof Sprite) { started.addAll(hat(p, msg, (Sprite) d)); } } return started; } private static ArrayList<Thread> hat(final ScratchPlayer p, String msg, Sprite s) { ArrayList<Thread> started = new ArrayList<Thread>(); final Object[] script = s.scripts; for (int i = 0; i < script.length; i++) { final String[] hat = getHat(script, i); final int hpos = i; if ((hat[0].equals("EventHatMorph") && hat[1].equals(msg)) || (hat[0].equals("MouseClickEventHatMorph") && msg.equals(HAT_MOUSE_CLICK_EVENT))) { EventHatThread t = new EventHatThread(hat[1], s, p) { public void run() { try { execHat(p, (Object[]) ((Object[]) ((Object[]) script[hpos]))[1]); } catch (Throwable e) { if (e instanceof ThreadDeath) { return; } e.printStackTrace(); } finally { p.hats.remove(this); } } }; t.setPriority(Thread.MIN_PRIORITY); p.hats.add(t); t.start(); started.add(t); } } return started; } public static void broadcast(ScratchPlayer p, String msg) { hat(p, msg); } public static void broadcastAndWait(ScratchPlayer p, String msg) throws InterruptedException { ArrayList<Thread> thrds = hat(p, msg); for (Thread t : thrds) { t.join(); } } public static void execHat(ScratchPlayer p, Object[] hat) { for (int i = 1; i < hat.length; i++) { execCmd(p, (Object[]) hat[i]); } } public static Object execFunction(ScratchPlayer p, String f, Object... param) { slow(); Function func = p.functions.get(f); if (func == null) { System.err.println("Error: Can't find function \"" + f + "\"!"); return null; // throw new RuntimeException("Can't find function \"" + f + "\"!"); } if (func.preExecute()) { for (int i = 0; i < param.length; i++) { if (param[i] instanceof Object[]) { param[i] = execCmd(p, (Object[]) param[i]); } } } try { return func.exec(param); } catch (java.lang.IllegalArgumentException e) { throw new RuntimeException("Error! False inputs for function \"" + f + "\"!"); } catch (java.lang.IllegalAccessException e) { throw new RuntimeException("Error! Isn't allowed to access function \"" + f + "\"!"); } catch (java.lang.reflect.InvocationTargetException e) { if (e.getTargetException() instanceof ThreadDeath) { throw new ThreadDeath(); } throw new RuntimeException("Error in function \"" + f + "\"!", e.getTargetException()); } } public static void slow() { try { if (Math.random() > 0.5F) { Thread.sleep(1); } } catch (Exception xe) { } } public static Sprite toSprite(ScratchPlayer p, Object obj) { if (obj instanceof Sprite) { return (Sprite) obj; } for (Drawable d : p.drawables) { if (d instanceof Sprite) { Sprite s = (Sprite) d; if (s.getName().equals(toStr(obj))) { return s; } } } return null; } public static int toScratchX(int javax) { return javax - 240; } public static int toScratchY(int javay) { return 180 - javay; } public static Object execCmd(ScratchPlayer p, Object[] arr) { if (arr == null || arr.length == 0) { return null; } if (arr[0] instanceof String) { Object[] param = new Object[arr.length - 1]; System.arraycopy(arr, 1, param, 0, param.length); return execFunction(p, (String) arr[0], param); } else if (arr[0] instanceof Object[]) { return arr; } else { throw new java.lang.UnsupportedOperationException(arr[0].getClass().getName()); } } public static void execList(ScratchPlayer p, Object[] cmds) { if (cmds == null || cmds.length == 0) { return; } if (cmds[0] instanceof Object[]) { for (int i = 0; i < cmds.length; i++) { execCmd(p, (Object[]) cmds[i]); } } else { throw new java.lang.IllegalArgumentException(cmds[0].getClass().getName()); } } private static String[] getHat(Object[] script, int i) { Object[] hat = (Object[]) ((Object[]) ((Object[]) ((Object[]) script[i])[1]))[0]; if (hat.length == 2) { return new String[]{ hat[0].toString(), hat[1].toString() }; } else { return new String[]{ hat[0].toString() }; } } public static class EventHatThread extends Thread { private Sprite owner; private String msg; private ScratchPlayer player; public EventHatThread(String message, Sprite s, ScratchPlayer p) { owner = s; msg = message; player = p; } public String msg() { return msg; } public Sprite owner() { return owner; } private ScratchPlayer player() { return player; } } public static abstract class Commands { public abstract String[] getCommands(); public final Function[] getFunctions() { String[] cmds = getCommands(); Function[] f = new Function[cmds.length / 2]; Method[] methods = getClass().getDeclaredMethods(); for (int i = 0; i < f.length; i++) { for (Method m : methods) { if (m.getName().equals(cmds[i * 2 + 1].replace("[raw]", ""))) { f[i] = new Function(cmds[i * 2], m, this, !cmds[i * 2 + 1].endsWith("[raw]")); break; } } if (f[i] == null) { throw new ScratchPlayer.PlayerException("Can't load Method \"" + cmds[i * 2 + 1] + "\" for name \"" + cmds[i * 2] + "\""); } } return f; } public Sprite owner() { return ((EventHatThread) Thread.currentThread()).owner(); } public ScratchPlayer player() { return ((EventHatThread) Thread.currentThread()).player(); } } public static class Function { private final Method m; final String name; private final Commands c; private final boolean preExecute; public Function(String name, Method m, Commands c, boolean pexec) { this.m = m; this.name = name; this.c = c; this.preExecute = pexec; } public boolean preExecute() { return preExecute; } public Object exec(Object... param) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { return m.invoke(c, param); } } }
And here are the "control" blocks.
import static org.me.scratchplayer.ScriptExecuter.*; public class CmdsControl extends Commands { // here are the names of the blocks in Scratch and their names of the block's function // in Java @Override public String[] getCommands() { return new String[]{ "broadcast:", "broadcast", "doRepeat", "doRepeat", "doBroadcastAndWait", "broadcastWait", "wait:elapsed:from:", "sleep", "doForever", "doForever", "doIf", "doIf", "doIfElse", "doIfElse", "doReturn", "returnHat", "stopAll", "stopAll", "doWaitUntil", "waitUntil[raw]", "doUntil", "doUntil[raw]", "doForeverIf", "doForeverIf", "say:", "debug" }; } // this method gets the return values of the parameters from the broadcast block, // the player() method returns the ScratchPlayer instance. public void broadcast(String msg) { ScriptExecuter.broadcast(player(), msg); } [... the other command blocks] }
Last edited by ZeroLuck (2011-12-29 05:58:08)
Offline
Uh no I can't program in Java . But I will test and make projects.
Offline
Sorry, I don't know Java But I could help testing and making test projects I linked you to one above. Could you convert that please? One more thing, would you be able to release a beta version or something of the converter?
Offline
WindowsExplorer wrote:
Sorry, I don't know Java But I could help testing and making test projects I linked you to one above. Could you convert that please? One more thing, would you be able to release a beta version or something of the converter?
The problem:
Rotation, scaling and graphic effects are (the only things) which are not supported yet!
But I will release the next version in near future!
And in the next version you will be able to open your own .sb files!
Last edited by ZeroLuck (2011-12-29 16:04:17)
Offline
ZeroLuck wrote:
WindowsExplorer wrote:
Sorry, I don't know Java But I could help testing and making test projects I linked you to one above. Could you convert that please? One more thing, would you be able to release a beta version or something of the converter?
The problem:
Rotation, scaling and graphic effects are (the only things) which are not supported yet!
But I will release the next version in near future!
And in the next version you will be able to open your own .sb files!
can you release the current version now please?
Offline
WindowsExplorer wrote:
can you release the current version now please?
Sorry, I don't want because:
1. You won't be able to open your own files now.
2. I first want to make rotating and scaling and graphic effects work.
(Because your projects are using them too!)
3. It has some glitches yet.
Do you understand me?
Offline