Skip to main content

News

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Rhuan

421
I've made memory leaks in Sphere before - you just have to find a way of continually bringing more objects into scope without letting old ones go out of scope, a while back I scripted a game menu with various sub menus, if you closed a submenu it called the game menu function again - the original instance of it was still open, so if you went in and out of sub menus without closing the whole menu you would burn up your memory pretty fast. (there were several other things wrong with that script - it was loading various graphics files for the menus only when they were called - which in this case meant the potential loop was loading those graphics files over and over.

if the graphics had been loaded once at the start of the game the problem would have become unnoticeable.

OR if the functions had terminated properly and dropped back to a controlling function that would then call the next function rather than trying to call the next function themselves the problem would have been avoided.

Either way I've learnt that you can make memory leaks in sphere and with the pieces I'm looking at at the moment the functions I'm using to update arrays are being called repeatedly - potentially every frame, and so if I'm accidentally duplicating the arrays and not letting the duplicates drop out of scope it could be bad...
422
Engine Development / Re: miniSphere 4.5.11
Good to see that updates are still being made.

I'd like to do an updated build of miniSphere for mac, when would be a good time for me to grab the source?

(I.e. when no major changes are about to happen)
423
Thanks for all of the replies, sorry for the slow turn around, life got in the way.

I've now scripted Dijkstra's Algorithm and it's working nicely, the key thing that Breadth First can't do as far as I understand that Dijkstra could do is have different movement costs for different nodes and ultimately find the cheapest route to each point - a feature I wanted.

A* is all about optimising the search to find a specific goal node which is not something I wanted at the moment as I wanted to find all possible destinations with cost below a certain amount so a player or AI can choose how to use their movement from possible options.
424
This is a question on how javascript (or at least sphere/minipshere's implementation of it) handles scope when it comes to arrays and objects; this may just be a problem arising from my scripting/programming knowledge being 90% self taught - I don't know how some of these things work.

Suppose I create an array inside a function:
Code: [Select]
function my_func()
{
  var my_array = [];
  ...
}

Now further suppose I wish to update that array inside another function:
Code: [Select]
function other_func()
{
  ...
  my_array[2] = 5;
  ...
}

Obviously this will not work as the array is not in scope, now let's suppose instead I pass the array as a parameter to other_func:
Code: [Select]
function my_func()
{
  var my_array = [];
  other_func(my_array);
  ...//do something else with my_array which relies on the 3rd value being 5
}

function other_func(param)
{
  param[2] = 5;
}

The second function will now not have a scope problem, but I think I'm right in saying that back in the first function will also have that value of 5 available to it, is this right? And is it appropriate to rely on this behaviour? I had instead been intending to have other_func return the array after updating it and have my_func overwrite the array with the returned one - is this functionally different?
Code: [Select]
function my_func()
{
  var my_array = [];
  my_array = other_func(my_array);
  ...//do something else with my_array which relies on the 3rd value being 5
}

function other_func(param)
{
  param[2] = 5;
  return param;
}


Is either of the above suggestions better than the other?
Is there any difference if the array is a property of a different object and you pass either the full object my_obj or just the array my_obj.my_array as a parameter?
Can getting this wrong create memory leaks?
425
Engine Development / Re: minisphere 4.3.8
You can get a second hand mac mini or macbook for fairly cheap if you just want any device that will run osx. If you're looking for a high spec machine to last for a long time then the price gets high fast though.
426
Thanks Radnan, that second tutorial in particular is very helpful - I'd already seen the first one though reading it a second time it's starting to make more sense.

It seems what I need is Dijkstra's Algorithm (as I want to find paths to all possible points) and not A* or JPS which focus on finding the shortest route to one point only.
427
I studied pathfinding maths about 7 or 8 years ago... I can't remember much of it at all, and I've never written any code involving pathfinding.

I'd like to write a pathfinding algorithm in sphere and don't know where to start - I've been looking around and tried reading up A* and JPS but most things I can find are pitched too high for me I could do with a simpler introduction.

Ultimately I'm looking to write something I can use in Sphere that will do the following thing:
Given:
- a weighted graph
- a starting point
- a maximum path cost
Calculate:
- all possible destinations
- the cheapest path to each destination

But for now please could I have some very introductory pointers
428
Engine Development / Re: minisphere 4.3.8
I hope you're not buying a macbook just for minisphere? They're a tad expensive...

I should be able to try and track down the bug at some point I haven't into it too much as I have ways of gettign around this - as said it may just be something I messed up on compilation - I built miniSphere and Allegro and most of the other dependencies from scratch using my own xcode project I didn't use any of the provided makefiiles so there's a lot of room for me to have got something wrong.
429
Engine Development / Re: minisphere 4.3.8
Maybe I something I messed up in the compilation, seems super odd though yes.
430
Engine Development / Re: minisphere 4.3.8
Ok So the image size was a mistake I'd made - I's downloaded the thumbnail rather than the actual image... Adjusting to the proper image gives the following two results.

The one with the half duplicated image is the one with the .createImage() calls in it the one where the only issue is the loss of transparency is without the .createImage() calls.

I do have a retina display but that's not relevant - it's only meant to cause problems if you move a window between the retina display and another screen - I haven't been using a second screen so can't test how this would work at the moment.

Edit: Found another issue, though this one is kinda minor. Savefile support, in sphere 1.5 if you write a boolean to a savefile it writes it as 0 for false and 1 for true it detects that it's meant to be a boolean from the default value you give it when loading. Whereas minisphere will write true and false, so any savefile with booleans written by one is not readable by the other.
431
Engine Development / Re: minisphere 4.3.8
So I ran it on my mac build of miniSPhere and got two problems....

Firstly duplication of the text and secondly blue background.

Note the difference between the two screenshots;

This code produced the one with the duplication:
Code: (javascript) [Select]
const prim = require('prim');
var image = LoadSurface('Title.png');
var slice1 = image.cloneSection(0, 0, 300, 75).createImage();
var slice2 = image.cloneSection(0, 75, 300, 75).createImage();
while (!IsKeyPressed(KEY_ESCAPE)) {
        prim.fill(screen, Color.Chartreuse);
        image.blit(0, 0);
        slice1.blit(300, 0);
        slice2.blit(300, 75);
        screen.flip();
}


This code prodcued the one without the duplication:
Code: (javascript) [Select]
const prim = require('prim');
var image = LoadSurface('Title.png');
var slice1 = image.cloneSection(0, 0, 300, 75);
var slice2 = image.cloneSection(0, 75, 300, 75);
while (!IsKeyPressed(KEY_ESCAPE)) {
        prim.fill(screen, Color.Chartreuse);
        image.blit(0, 0);
        slice1.blit(300, 0);
        slice2.blit(300, 75);
        screen.flip();
}


In both cases the transparency is lost.
432
Game Development / Re: The Screenshot Thread
Beaker: wow the Rainis Manuscript that game had reached near legendary status back when i first used Sphere in around 2005...
433
Engine Development / Re: minisphere 4.3.8
Thanks for the pointers... Not so sure on learning this new api, I know the old one so well that trying to replace it in my mind would be a lot of effort.

As for the other points, no rush - you've done an awesome job making a modern rebuild of sphere that generally runs faster and does stuff better whilst using a lot of code - the face that I can find a few bits that don't work at the moment isn't a massive issue.
434
Engine Development / Re: minisphere 4.3.8
And got another issue for you; this time an error in miniSphere.... Sorry I have a tendency to use obscure functions.

Background: I used an online sprite generator which creates an image output containing the various frames of the sprite; as I'm intending to use it quite a bit AND it also includes some stuff at the bottom which prevents sphere's image to spriteset tool working I wanted to write a script that could read lots of outputs form this sprite generator and make them into sphere spritesets (or some other custom spriteset format though probably the former due to the point in my previous post).

However miniSphere can't do it quite right - Sphere 1.5 running under Wine can.

Method:
1. Load the image as a surface
2. use nested loops to slice the image up surface_object.cloneSection(x,y,w,h).createImage();
3. do stuff with the resultant images

Problems (in each case no problem in 1.5 but a problem in miniSphere):
1. whilst the image loads with its background being transparent initially after it's sliced up the background becomes opaque in miniSphere - Sphere 1.5 keeps it transparent
2. the createImage() function in minisphere somehow fails to clean its buffer - if I remove the createImage step and blit  a few of my outputs in miniSphere they look ok apart from the transparency issue BUT if I put the createImage step back each frame becomes the result of bliitng all previous frames on top of each other seemingly with transparent backgrounds except a non-transparent background is added to the whole thing at the end.

edit: and another point miniSphere doesn't have the CreateSpriteset function.
- so far miniSPhere can run all my game code but not utility code - but sphere 1.5 under wine can run the utility stuff so it's ok

later today I'll try and post a completeness check of the miniSphere functions as I seem to keep finding ones it's missing.
435
Engine Development / Re: minisphere 4.3.8
Another question... Possibly more a feature request.

Something I wanted to be able to do before was make hybrid custom data files so I could store mixed game resources in one document. The problem with this is Sphere does not support converting a byte array to an image or sound or vice versa.

The only way I could this before with images was to write the image to a file then open it as a rawfile, read the data and then write it into my data file - then to load it read the data, write it to a temporary file with an appropriate image extension then use the LoadImage function - there was no version I could do at all with sound.

I had been hoping to use a custom spriteset format in the project I'm working on but it looks like I probably can't as it will involve way too much disk input/output to load it - shouldn't there be a facility to convert a byte array to an image or other equivalent functions without having to write it to disc?