Author Topic: Making the upgrade to miniSphere  (Read 445 times)

Offline East

  • Newbie
  • *
  • Posts: 12
    • View Profile
Making the upgrade to miniSphere
« on: April 16, 2017, 06:47:48 am »
Hi guys. So I recently came back to my Sphere game after a pretty long break (~7.5 years). I haven't been coding anything during this time so it takes me a while to get back but I think I'm starting to get the hang of things.

Anyways, I made my game back then in Sphere 1.5, and now when I got back and tried to upgrade it to miniSphere, I ran into some problems.

There are a number of old 1.5 functions which I used a lot in my code, that now don't work. For example, LoadSoundEffect(), which I changed into LoadSound() to not get an error message , but now whenever I use sound.play(), nothing happens I can only play one sound at a time. Another issue is, whenever I exit the engine, I get a crash message from windows telling me "miniSphere engine has stopped working". There are other things in the code that now just don't seems to work but I won't specify them, and instead I'll just ask, what do I need to learn in order to use miniSphere correctly. As someone who is not a coding expert (switched to sphere from RM2k, learned pretty much everything on the fly from the API and online guides), it feels almost like a different programming language.

I looked in the Sphere 2 API but I just don't know how to use most of what's in there. To use the sound example again, I saw in the API something about a mixer, with some dots and some hashtags and all I could think about is this.

TL;DR: after upgrading to miniSphere I'm back to being a complete noob, where can I learn how to Sphere?

Thanks :)
« Last Edit: April 16, 2017, 07:02:32 am by East »

Offline DaVince

  • Used Sphere for, like, half my life
  • Administrator
  • Hero Poster
  • *****
  • Posts: 824
    • View Profile
    • Vincent Beers portfolio
Re: Making the upgrade to miniSphere
« Reply #1 on: April 16, 2017, 01:17:56 pm »
Hi! First off, welcome back to Sphere! :D It's always nice to see some interest in the engine return.
The thing with Sound.play() (as opposed to SoundEffect.play) is that if it's the same sound effect, it'll just resume (or effectively do nothing if it was already playing). One way to circumvent this is to stop() the sound and play() it again if it's the same sound, or to make an entirely new instance of LoadSound() and play that back separately.

As for the crash, well, that's a thing for fat cerberus to find out. The engine is never supposed to hard crash.

Offline Radnen

  • Wise Warrior
  • Senior Staff
  • Kitty-Eating Cow
  • *****
  • Posts: 1409
  • Sphere Studio Developer
    • View Profile
    • Radnen's Hub
Re: Making the upgrade to miniSphere
« Reply #2 on: April 16, 2017, 07:35:44 pm »
it feels almost like a different programming language.

Later RM's used the Ruby programming language, but the latest RM is now using JavaScript, so actually learning Sphere's JS would in fact help you out if you do decide to return to RM someday down the line. :) That said, I don't think RM2K had any programming besides logic statements in the action/event editor which is in fact a form of programming and a feature I would have liked to build into the editor someday (basically it turns RM2K style events from a point-and-click editor into Fat Cerberus's scenario.js scripts).
If you use code to help you code you can use less code to code. Also, I have approximate knowledge of many things.

Sphere-sfml here
Sphere Studio editor here

Offline East

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Making the upgrade to miniSphere
« Reply #3 on: April 17, 2017, 06:01:47 am »
... So apparently the crash was because of me using the sound mixer in some very bad way. I managed to fix it and even managed to make the sound effects work using the mixer! I actually love how easy it is to configure now.

I saw you guys speak about JSON in a lot of the miniSphere and Sphere Studio threads here, so I went and learned me a bit of JSON (had no clue what that is at all), and it helped me understand how some of the things in the v2 API work.

But... my game's battle system still doesn't work smoothly in the new engine. Lots of entity-movement stuff that I guess I need to rewrite. So for the moment I'm back at the 1.5 editor, I just don't have enough free time to make the upgrade AND work on the game right now, as much as the new editor looks good and comfy.

Offline Fat Cerberus

  • miniSphere Developer
  • Global Moderator
  • Kitty-Eating Cow
  • *****
  • Posts: 2228
  • *MUNCH*
    • View Profile
Re: Making the upgrade to miniSphere
« Reply #4 on: April 17, 2017, 12:50:25 pm »
@East: Could you tell me exactly what you did with a Mixer that caused the crash?  In no case should the engine crash outright, even if there's a bug in your own code.  It's a sandbox environment, after all.

I definitely recommend looking into miniRT first, being new to Sphere v2.  The core v2 API is pretty low-level by design and not very beginner-friendly.  miniRT has a bunch of convenience stuff like the music module that make common game-development tasks much easier.
miniSphere 4.5.11 - Cell compiler - SSJ debugger
Forum Thread | GitHub Repo

Offline East

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Making the upgrade to miniSphere
« Reply #5 on: April 20, 2017, 03:06:20 am »
I couldn't remember exactly what I did that caused the crash so it took me a while to find it, but there it is:

Code: [Select]
var mixer = new Mixer(44,16);
mixer = new Sound;

It causes an error message on test (obviously), and then when I close the engine I get the crash.


Offline Fat Cerberus

  • miniSphere Developer
  • Global Moderator
  • Kitty-Eating Cow
  • *****
  • Posts: 2228
  • *MUNCH*
    • View Profile
Re: Making the upgrade to miniSphere
« Reply #6 on: April 20, 2017, 11:03:18 am »
Seems to be a bug in Allegro where creating a mixer with too low a sample rate succeeds (or at least returns a valid pointer), but then crashes when you later shut down the audio subsystem.  I've reported it.  Thanks!
miniSphere 4.5.11 - Cell compiler - SSJ debugger
Forum Thread | GitHub Repo