Project "Interstellar"

edited June 2015 in How To...

Hi, There is a huge project I have to finish during the summer months. I need to learn much to finish it, and I am a bit confused with some of the general directions I should take.

To the project itself.  We (a number of science teachers) are making an interface for an educational off-line role playing game. In the game the stdudents devide into two companies - "fleets" and investigate some universe from two different starting points. Every hour they make a jump from one planetary system to another. If they end up being in the same star system - they battle (by simple comparing the military powers of the fleets). In every system they collect resources. They don't how rich some system is before the make a jump.

During the turns (those 60 min between the jumps), students participate in a lot of off-line science and other subject activities thus earning  credits, that can later be turned into upgrades for their fleets. 

Forgot to say. The computer part of the game will be played in a local network, as there is no connection to the Internet there.  

Some possible extensions: - fleets are composed of individual ships, that can explore the system, before the star system jump. - there is an on-line shop where they can by the upgrades

The game is a "multiplayer" in some way, and the teams mustn't see their opponent's jumps, until until they meet in one system. Also, the game has to be as stable and proof to "users" as possible, as I anticipate a lit of "mis licks"  and other "strange" behaviour.

Initially I was thinking of programming everything from scratch in Processing. But now, after having looked through a number of options (I read a book about PHP and MySQL) I think, that maybe i should use HTML5 (p5) for display purposes and the main script should be implemented in PHP, where all the data is stored in MySQL. As for the online shop, I gave no idea, and I thought that there might be done open source ready to go solutions.

Any help / questions / ideas I highly appreciated, as I am a bit overwhelmed with the amount of things I have to do, and thinking where to start. And I know, that my question, strictly speaking, is not about processing, but people here are the most responcive I have met so far...)

Tagged:

Answers

  • Not sure about using HTML, you may do that but you may want to consider using a Network library. You'll have a server side for your shop, providing universe data, etc. and client side for your students to play. You can still access MySQL database from processing, if you need it to store data.

  • edited June 2015
    • For server-side, node.js or io.js are better alternatives to PHP language IMO, since it's JS syntax:
      https://en.wikipedia.org/wiki/Node.js
    • However, debugging for web or script languages can be much harder... :-SS
    • I agree w/ @Ater that for such big task a typed language can smooth the development a lot.
    • Processing has access to both net & database libraries. So it seems enough for what you seek.
  • edited June 2015

    This is a non-trivial project, especially if you don't already know what you're doing. I would be pretty surprised if you're able to finish everything you said before summer is over.

    I'm not saying that to discourage you, but you might seriously consider scaling down your expectations.

    Also, like you said, I don't see anything "inherently Processing" about this project. You could use it for a front end, and you could even use its database libraries, but that's really stretching what Processing was designed to be used for.

    What you have to do is break this down into separate pieces. At the very least, you've got three pieces: the database, the server, and the client. You generally start with the database, then figure out the server, and lastly figure out the client. Each of those three pieces can be further broken down into smaller steps.

    Generally work like this would be done by a team- at least one person for each of those three pieces. So taking it all on by yourself (especially if you aren't a programmer) is a pretty huge job.

    But, if you're really diving into the deep end and going for it, here is how I would approach it:

    Step 1: The database stores all of your information, so everything else depends on it. What database are you using? Do you have access to one at your school? You say you don't have an internet connection- do you have access to a server?

    Step 2: The server-side logic takes the information stored in the database and sends it to the client based on whatever game logic you implement. It also takes user input and stores stuff in the database. What server-side language and framework are you using? There are a ton of options here, from Java EE and Spring to php to node.js. They all have different pros and cons, but the final decision comes down to your personal experience as a programmer.

    Step 3: What should the client-side look like? This is arguably the least important part (it doesn't matter how beautiful your website looks like if you don't have a database), but it's the part that people focus on the most- notice how you've described how the client should behave, but not at all any of the underlying pieces, which are the "meat and potatoes" of the whole thing.

    I can get into more specifics if you want (shameless self-promotion: I run an open-source web project called Static Void Games that you could use as a skeleton starting point), but this is seriously a lot of work for one person, especially if you're not a web programmer.

  • Well you are right, that is a pretty big piece of cake, still I would like to give it a shot.

    There is a couple of things I know how to implement: - I know how to do simple operations with MySQL and PHP - I know how to send information back from an SQL database to the html page. MySQL -> PHP -> JSON -> p5

    (I made a small project where a PHP script randomly put "x" and "y" into the database and then I made a JavaScript connect to the database and present draw the planets in the appropriate places on the canvas. )

    A year ago I was working on a different project where we tried to create a spaceship with a number of control panels in different classrooms where we ran processing client codes. The central screen with the processing server code showed everything.

    In general, your description is correct my experience is limited. Seems I'll in for some work:)

    Any comments / details would be most welcome.

  • BTW, if you could help me to scale it down, that would also be wonderful.

  • Well, step one is to figure out what your setup is going to be. If you already know some mysql and php, then that's probably the way to go.

    I'm a Java guy, so it made more sense for me to use Java EE and Spring. More than one way to skin a cat, and all that.

    Then once you know your setup, step two is to get a "hello world" up and running. Can you have a very very basic webpage reading something from a database? Okay, now can you have something very very basic writing to the database?

    From there it's "just" a matter of picking a bare minimum, smallest next thing you know you need. If user logins are going to be essential, then that might be one of the first things you implement. Repeat that process until you have something that resembles your initial goals.

  • Given your experience with php / mysql I'd stick to HTML output for the client: it's pretty straightforward to interface web pages with that back end, easy to create html forms for input, and to generate text output. Compare that to setting up forms and output in processing, even using appropriate libraries, and to me it's a no-brainer. And if you do want visual output on canvas you could always use p5js ;)

    As @KevinWorkman says concentrate on the interaction on the back end to begin with: you can build a surprisingly compelling game environment in plain text; then add visual stuff later. Then if time becomes an issue you still have something 'finished' to work with...

  • Good,thanks so much! I will keep posting my progress, then.

  • nice ideas!

    some thoughts..........................

    Classes

    ok, your classes could be

    • Fleet // has name, position, military power / special machines to harvest different minerals / average health of crews / average damage on ships..... etc.

    • Starsystem // describing text / ressources / maybe image

    • Resource // collected / owned by fleet / lithium ...

    the whole data (ammo, fuel, machines....) must be saveable so the game can continue next day...

    Layout

    The hyperdrive jump could be visualized by a typical starfield with stars becoming lengthy lines (millenium falcon in star wars jumping). Often seen in the forum.

    otherwise I would stick to text first, describing the starsystem to the players and show one image of the system:

    Your fleet arrives in an old system with a vast red giant at its center - a very old sun near its final death.

    3 rock planets are all that's left from the former 7 green and rich planets circling it.

    or for encountering the other fleet:

    The first commander of the flag ship suddenly shouts: We detect another fleet. They are sending small fighters on our right side. Your fleet puts up the front shields and do evasive manouevers. It is a terrible fight against this frightening black fleet. .... and then the result - losses who wins, one fleet flees the system....

    Also a cool Frame story would be fancy:

    https://en.wikipedia.org/wiki/Frame_story#Use_of_frame_stories

    maybe the fleets have an image or an Coat of arms or a name (or a name that the students can choose)

    Decisions:

    the students must make decisions. So we have command buttons for the menus.

    being in-system

    • investigate planet 1

    • investigate planet 2

    • harvest lithium on planet 1 (<- you can't: missing lithium harvester (machine))

    • leave system (see: to which other system?)

    (being out of system would not occur, because you decide to which system you go next when you are still in-system).

    to which other system?

    • provide a list of systems or a map of the part of the galaxy with stars and names in it

    Question

    you wrote:

    In the game the students devide into two companies - "fleets"

    does this mean, all students work on 2 computers, since there are two fleets? That would be straightforward. When each student in one fleet has their own computer, how would the interaction be? Voting over the next action? (Given, that single ships in the fleet are not distiguished yet.)

    here I am bit lost:

    During the turns (those 60 min between the jumps), students participate in a lot of off-line science and other subject activities thus earning credits, that can later be turned into upgrades for their fleets.

    Question: these are offline activities. And they earn points. And they are then entered into the system / computer so the fleet gains ammo or military power or fuel... or machine like my lithium harvester? So there is a tutor enering the resulting fuel gain? Then the game has an Admin with a password? Or do the team itself get a code like khe37 and then when they enter it, the fuel comes in?

    We wish success and fun!

    Best, Chrisir ;-)

  • With a blazing light a vast fleet suddenly spawns before your fleet.

    A fleet of long sleek ships all in white, spires and towers gleaming with bright light.

    The entire fleet was blazing with sheer fire power.

    If angels needed ships, they would look like this.

    Angels of destruction.

  • edited July 2015

    Chrisir, thanks for all the feedback! The last description seems like it is from the Warhammer universe.

    As for the questions,

    • I thought of 'installing' the hyperdrives only on some ships, so that each fleet has 2-3 'jump carriers', so, basically, we have 2-3 fleets on one side and 2-3 on the other. I haven't thought it over in detail yet. Especially the process of dividing the ships in the game process.

    • I thought the students will get the codes, which they will enter into the system to get 5 / 10 /1 15 'energons' (credits) that they can later turn into fuel / ships.

  • the text is written by me

    ;-)

  • Hmm, I have finished the following things:

    • fleets can travel from system to system
    • there is an html-text representation of what is happening.

    However, now I face a conceptual question: - my galaxy has around 50 starsystems - each starsystem can have up to 5 planets - each planet can be rich in up to three different resources

    Now, if "galaxy" is a database, then - starsystems are tables? If yes, then I end up having about 50 tables, which is a lot, right?

  • Each star system would not be a table.

    One way to design this would be to have a PLANETS table. Each row of that table would represent a single planet, and would contain columns telling you which star system it belonged to, which resources it has, etc. To get the planets of a particular star system, you would just get the rows that match the criteria.

    You would probably have other tables to hold supporting data, but it sounds like you'd just need the one table to accomplish what you've just described.

  • yeah, one table PLANETS, one table starsystems

    each star systems knows the IDs of the planets it has

  • Ok, fixed the previous issue with the tables. On a new one!

    I looked into how to implement the 'log in' thing in PHP. And that.s still a big piece to bite. So, I will stick to the password option, where, for every action the users will have to enter the password.

    Now, I could code the "access' script into every PHP file I have, but that.s a lot of repetition, so I decided to setup a "login.php" file where all the authorization will take place, and if everything goes as expected some variable will be set to "true".

    I am planning to "include" this file into all other PHP files (jump, scan, build, ...). The question is: when I "include" something, does it work as a function? So that all of the variables are locL, or does it really add the code to the file?

  • Sorry for disturbing, I figured it out. All the variables I the file will be accessible later in the second file.

  • edited July 2015

    Now, I come to the next conceptual point, which I need help with.

    Q1: What if two opposing fleets meet in one starsystem, say Gemini. If they are composed of one strikeforce each, then - no problem, the one with the biggest 'militaryPower' wins.

    However, what if both of them are composed of two or more strikefores, then, I have to add up their militarypower indexes.

    Let's assume, that the compositions are as follows:

    FLEETA
    -strikeforce A1: 20
    -strikeforce A2: 15  
    -strikeforce A3: 30
    net: 65
    
    FLEETB
    -strikeforce B1: 5  
    -strikeforce B2: 15
    -strikeforce B3: 35
    net: 55
    

    So, FLEETA wins, however, how do I go around distributing the damage points?

    strikeforceA2 + strikeforceA1 are wiped out completely? Or, rather, the difference (10) is divided equally between the three strikeforces?

    Q2: Do the fleets battle the moment one jumps into the occupied system (realtime game) or do we have, say, turns (every 30 min) and the battles are resolved at the end of each turn?

    Feedback is very much appreciated! :)

  • IMHO, these are questions that you need to answer by yourself, as a designer of the project. There are examples of games that use both of described methods (for both questions). However, here are some thoughts that you came for.

    You can organize battles in turns say A1 attacks B1, A2 - B2, A3 - B3 this destroys B1 and B2 and A2, then B3 attacks A1 and when it is destroyed FLEETA wins. However this method is less interesting while you only compare 1 parameter for a battle. If you'll have separate attack and defence attributes for each ship, there may be more interesting combinations with more then 2 turns possible. You can also add separate items in your shop for attack and defence upgrades that will provide your players with more strategic options. Sometimes a randomness is also added, so attack may be poor, normal or critical. This may make your work harder, so it is still an option just to divide damage between all ships in winning fleet, but there is also a question on how do they get repaired and respawned. I mean what is harder to do to repair a damaged ship or to get a new one. Combining these parameters is a game balance and you may need to test a couple approaches.

    For your question two, I would go with the immediate battle, as it would be more clear. It is usually impossible to perform any actions while you have enemies near you.

  • Thank you for the reply, I just thought there might be some hidden issues I might be unaware of. I will still have to weigh the approaches, unfortunately, as I don't have much experience, I don't know which approach might be the most costly, but, then again, it will be fun to figure it out.

    One of the biggest problems I've come about is that I have to add some features, that I have never thought of before. To implement them, I need to rewrite pieces of code here and there. Now, these pieces are 'connected' to other pieces, which, become broken and have to be fixed also.

    While fixing those I sometimes even forget what caused all the trouble in the first place - so I have a notebook for that now. I know, this sounds ridiculous but this is how it is at the moment :)

  • a fleet can't be wiped out because then the entire game would be over

    So within your setup/ layout of the game, one fleet gets heavy losses and then flees / jumps

    It can lose ships and buy new ones later

    To keep it simple I won't recommend battle of single ships - only battle of the 2 entire fleets

  • Ok, I seem to be getting into every well known issue there is with my project. My current problem is how to restrict sending the form info if the page is refreshed.

    Now I googled the problem (a very infamous one), and it seems, the most reliable way is to use cookies and session ids, however, I don't feel like I am ready to dive into 'cookies' now. Is there a simpler way (may be not as secure?) to solve the problem? For now?

    It is not about laziness, just I found this loophole a couple of hours ago and I want to close it the easiest way possible, and then finish other items before getting back to "sessions", "ids", ...

  • I don't know.

    Maybe make a new question in section network?

  • Thank you anyway!

    I solved the problem by just creating another page and after the authorization the user is sent to that page, and then back to the main menu. It so happens, that the browser somehow forgets the data that was filled in the form, so the 'refresh' button stops working - which is handy!

  • Ok, this is my first alpha (or beta, or how do you call it :)

    I KNOW it is not good practice to ask an id and a pass FOR every action, but this is just the start.

    This is the link to the page. I would appreciate any feedback, thanks!

    http://spacej.ru

  • edited July 2015

    I would recommend to decrease the timer for testing reasons, cause 10 min is too much.

    In general, its OK. I was able to do mining and make a jump to a different system. I didn't get how the shipyard works, as there was no message after I entered the item Id.

    I can only give a feedback on appearance, not functionality. First is the messages should have some delay, like "doing that" a second then "doing this" and so on, so there would be a feeling of a process. And second is that you may use a little bit of css styling and the look would be much better, you can use some templates from internet. You have a good progress, please continue)

    Edit: Also it's a little bit hard with the names of systems, planets, etc. You may either make dropdown lists to select available options, or at least make some naming convention, like 3 letters + 3 chars for a planet and so on.

  • very impressive

  • edited July 2015

    Chrisir, thanks!

    Ater, 1) changed the time 2) shipsyard - you are right - there is no message (which is my mistake), but as you buy something the resources are decreased by the price and you get the MP of that ship. 3) with delays - that was my intention - and this is probably my next update:) 4) with names - I thought of compiling a list of names and then using one of those. The second thing is - to make a drop down list the PHP has to know which fleet is doing that - and since there is no 'log in' I couln't do that. I think, when I implement the authorization thing - I will be able to make the interaction easier.

  • Hi, changed the outline of the site. Couldn't find the ccs template that I'd lik, so I came up with my own.

    Read about and implemented sessions - means, you don't have to type your pass again and again.

    Coming closer to using Processing to show something)

    spacej.ru

  • edited July 2015

    Ok, after a few days I was able to connect the p5.js drawing tools with my MySQL bases. Now - if you register your fleet -you are then taken to the map screen - where you can look at the nearby stars. There is also a mainMap button at the bottom - where you can see all the other fleets.

    For now the project is finished, I will wait till the school year begins to ask students to test it.

  • Answer ✓

    Congratulations!

Sign In or Register to comment.