We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello, I was not sure about where to write, so I decided to write here.
I am thinking about starting a very simple project (yet another one:) and I need some advice. The idea is to create an environment where people can code some spaceship behaviour and then play duel mathes.
Initially I was thinking of creating a library of sorts, which will have all the "ship-like" functions: throttle, thrust and so on. So that later someone trying to program a spaceship combat could load the library, initialize the 'ship' object and use it to program some unique behaviour.
It sounds confusing, I guess, but if you get the idea, you can probably tell me whether this is a good idea for processing, and if it can be carried out at all.
Thanks!
Comments
I am not at all an experienced coder, but I think it could work. You'd have to come up with some very innovative ideas for coding it with Processing. I'm thinking you might need to make the program save and load .txt files or something similar.
I have thought about creating a similar program with robots. The idea came from an early coding game called 'Core Wars' where opponents created programs in a fictitious language called Redcode, but I never got round to it. My QScript library was potentially the first step to creating my own Redcode style language for waring robots.
BTW I think it is an excellent idea and achievable but would take a lot of time and effort to do. :)
Hi. The link you shared is such a fun. You may try to implement the motion first and see if it was hard. You could still use JS for that.
Thank you for the feedback. At the moment I am looking for the inforamtion on how can one pass object as a parameter to some function.
Also I haven't found any info on how to set up a library. Do you kow of anything like that around?
In order to accept user codes for your game, you're gonna need some ScriptEngine:
http://forum.Processing.org/two/discussion/comment/25959/#Comment_25959
http://docs.Oracle.com/javase/8/docs/api/javax/script/ScriptEngine.html
In which we call eval("") over user's code:
https://developer.Mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval
Example
Where foo is an object of a class called Foo
Try here
you can start without doing a lib first
you need an text editor inside your sketch and a means to excute it to move spaceship
Hey-hey! Stop:) I am not that proficient in Processing to do all of what you suggest now (even to understand some of the suggestions;), well, thank you for a head start anyway. Now I have something to think about.
To simpler matters: I think, I first need to create a model that will behave similar to a spaceship. I mean one can.t "just" rotate the ship, one needs to apply some thrust in the right direction and even after that, It is important to cancel the rotation and stuff you applying thrusts in the opposite directions. And on and forth.
My question is: if I start with coding a class in processing and then code all its methods in it will I be able to move it all to a separate library later on? Or is it important to start with the library in the first place?
I dont know
Here is a game that got me interested in programming and electronics in general: Robot Odyssey. Played it on a TRS80
The answer is yes provided you create it as a top level class. I will need to explain that. Java is an object orientated language which means ALL code must be written inside a class. Processing hides this from you but when a sketch is run Processing's preprocessor creates a class that incorporates the sketch code before compiling it. If you create a class in the main sketch tab it becomes an inner class to the one created by Processing. Inner classes should be avoided if you want to use them in a library later.
To create a top level class called
Foo
in Processing create a new tab calledFoo.java
note that it is named after the class and is case sensitive. This is essentialThe other thing is to use access specifiers (public, protected or private) to the class as well as ALL fields and methods. All though not essetial in Processing it will make it easier when you use Eclipse to make a library later. e.g.
Hi, This is a rather strange request, but I hope you will find some time to write a few lines!
Some of the students at school have just finished their ICT project. They decided to implement the idea I discussed above. This is their first year of programing (better to say first three months) (15 years old)
They also set up a site to present their results. It would be great if you could write something for them. English is not their native, just in case.
http://spaceprogramm.weebly.com/
Thanks!