123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|287|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> JSE -> JSE - Jay's Scripting Engine

Page : 1 2 3 4 5 6 7 8 9 10 11 12 13 Prev 14
Next
Fri, 03 Jun 2022, 06:12
Jayenkai
Found it!
When reading from the file, it's assuming they're strings instead of floats.
If you wrap things into floats, it works fine.. Eg
ax=Float(ReadFile(ding))

Ok, so I'll have to add in ReadFloat, ReadInt, etc..

-=-=-
''Load, Next List!''
Fri, 03 Jun 2022, 06:31
Pakz
Ok, that I had not thought of yet.

During hunting for bugs I found a new one. Here if I disable one new dim. There are no debugging messages. If I enable the dim then there are debug messages.

The ' tmplx(20)' one

  --v

Fri, 03 Jun 2022, 06:54
Jayenkai
Yeah, I'll have to work out how to do error messages like that..
Currently the language has a tendency to ignore and carry on regardless for a LOT of quirks.
(Very much NOT Strict mode!)

In this case, if you don't Dim an array, it won't whinge when it comes across it. It just .. sort of steps over it, and ignores it!

When you DIM, the parser runs through looking for the name of the dim, and converts any code from eg MyArray(2)="bee" to SetArray("bee",MyArray,2). (Or something like that, can't remember the exact order)
There's also a similar GetArray, too.
When you DON'T dim the array, none of that gets set up, and when the parser encounters weird things like MyArray(2) it just kinda goes "I don't know what to do with this!!" and steps right on over it!

-=-=-
''Load, Next List!''
Fri, 03 Jun 2022, 07:02
Pakz
It is fun. But frustrating when things do go according to plan

I started this morning to go and capture the game state just before a bug happens. I just got it working. It is close to dinner now though

Now when I press the 'b' key the game resumes at a point where ' sometimes' a bug occurs. See if I can add some code to prevent the cars driving through each other!
Fri, 03 Jun 2022, 13:13
Jayenkai
  --v

OK, the new collision detection functionality is in.


The main draw commands (Rect, Triangle, Oval, DrawImg, Line, Plot) now have return values, which reference their associated collision value..
So if you do, say "MyCollision=DrawImage(10,10)" then "MyRectCollision=Rect(100,100,200,200)", then you can test for a collision between those two items using "Result=Collide(MyCollision,MyRectCollision)"

It's not quite flawless, yet.
In the example above the images vs the oval are being a little bit generous with their collision, leaving a slight gap between the two.


Rectangles won't rotate, but they never did anyway, so that's ok.
Anything "Oval" will assume a circle, so you can't collide hexagons, etc.
Text doesn't yet collide. I need to double-check everything before I can do that.

But otherwise it's a fairly decent start.

Here's my original test engine.. Click to change the object at the mouse cursor.
> Reveal 🔎

Note : New collision methods may be slower than old collision methods. As such, in most cases, you might be better off using the old commands. They've been left there, in case you do.

-=-=-
''Load, Next List!''
Fri, 03 Jun 2022, 14:02
Pakz
Looks impressive. The top example code looks a bit complex

Those triangle and rotating boxes can come in handy.
Sat, 04 Jun 2022, 04:36
therevillsgames
Next up Box2D JSE!
Sat, 04 Jun 2022, 04:45
Jayenkai
  --v


(Collisions work, but my physics code is bloody awful!!)

-=-=-
''Load, Next List!''
Sat, 04 Jun 2022, 05:30
Pakz
If you ever feel like adding something special for data. A hash table like the one used in Lua is great. Infinite size. Quick lookups. Small.
Sat, 04 Jun 2022, 05:47
Jayenkai
How would you use it?
Write a little fake example of what you want and how you'd use it.

-=-=-
''Load, Next List!''
Sat, 04 Jun 2022, 06:02
Pakz
Well. I had a 2d space game and could just create a area say at map position 500,500 width a width and height of 100,100. Everything else in the table would just read nill and use no memory. I can create a huge map in that way by just leaving everything empty and populating certain area's.

You just create a array but without a dimension. This is infinite.



Then you can read any number from there. If there is nothing inside then it reads Nil. If there is anything in there. Then it returns the value.

It works with strings in a similar way. Just populating the strings where they are at. This works different than Dim though. Insert and remove and such. I mostly like the infinite dim feature of it all.

You could call them infinite arrays?

Edited...edit2
Sat, 04 Jun 2022, 06:17
Jayenkai
Yeah, that might be a memory issue. I'm already using a ton of memory behind the scenes!!

-=-=-
''Load, Next List!''
Sat, 04 Jun 2022, 06:20
Pakz
Yes. That is where those hash functions come in. They store only the used data. I have found some code before. Not sure where I found these. I need to look.

Edit:

Quick lookup: no idea if this is useful. I only ever used this when it was implemented already.

https://www.freecodecamp.org/news/javascript-hash-table-associative-array-hashing-in-js/

Edit. More reading. That infinite array is called a Sparse array Apearantly. They can go negative too. Javascript supports it.
Sat, 04 Jun 2022, 10:44
Pakz
I did some testing in javascript and the example above is supported by javascript. At least on the ios browsers. This is called sparse arrays.



Anything called from unused slots is returned as Default on my ios browser.
The array size is returned as the most positive or negative slot used.
Sat, 04 Jun 2022, 11:35
Jayenkai
I think you're probably hitting a limit of what JSE was meant to be.

-=-=-
''Load, Next List!''
Sat, 04 Jun 2022, 12:46
Pakz
One quick bug. On the iphone.

The "" characters for strings are not on the on screen keyboard. It auto selects a opening " and uses and closing " after that. Jse wil not compile with these quotation marks. If i copy them from the docs it does compile.

Maybe I can find a setting somewhere. But at default it does not have it. There is a setting for this I just noticed.
Sat, 04 Jun 2022, 12:48
Jayenkai
Example..

  --v


ALL this is doing is flood-filling an array of "only" 1024x1024x10 elements.
In "Javascript" this would take about 0.2 seconds. I regularly do this in both Browsercade and Shoebox, between levels, or when switching games and such.

In JSE, though, you're not only battling the memory, but also just how long those for-loops ACTUALLY take for an interpreted language like this.
Even with an infinite amount of memory, it's just going to be completely unusable with the speed of the language itself.

Even my "biggest" game, Futrino Emissions takes about 4 or 5 seconds to build a level, and that's only 160x160 tiles in size.

There just isn't any real-world value in making you wait longer and longer for large arrays like that.
I know "It could be useful for x/y/z", but honestly if you're finding that, you're probably better off not doing the task in JSE.
JSE's not THAT powerful!!!

-=-=-
''Load, Next List!''
Sat, 04 Jun 2022, 12:58
Pakz
Javascript arrays are a hash table in itself I think. You have access to any configuration by just writing into it. It only uses memory if you create something in the array. If you put one integer at -10000 them it is the same as creating a single item array. It is a linked list system or something like that. You do not have to fill every item in the array.
Sat, 04 Jun 2022, 13:02
Jayenkai
OK, what would you use it for?

(Bugfix for unicode issue uploaded, refresh for the fix)

-=-=-
''Load, Next List!''
Sat, 04 Jun 2022, 13:29
Pakz
It is a memory saver for one. You can have a tilemap and tilemap layers and it only uses memory for the tiles that are set. Anything not used used in the arrays uses no memory and return a default empty.

I have a space game where I could theoretically just fly forever. Generating points of interest in the space around me. There is no need to code a complex system. I stil have no clear idea how to code huge worlds without these unlimited arrays.

You do not have to create a array and set its bounds and fill the memory first. You create it while you first use anything in it.

I have only discovered this feature last year. So I have not many use examples yet and might not be able to explain its potential.

Edit: no more array out of bounds errors and negative array values
Sun, 05 Jun 2022, 04:48
Jayenkai
  --v

Whenever I try to code something vast, I try to keep one key thing in mind.

A ZX Spectrum only had 48kb, and yet it managed to hold the entire universe of Elite.
Instead of storing everything, randomise it.
Use the power of Random Seeds to generate everything on the fly, as and when you need it.

In the above example, the galaxy is popped into an array, but once you hover the mouse over a star, that star's system is pseudo-randomly generated, as are the names of the system and its planets.

Hold up and down to flick through millions of different galaxies.

-=-=-
''Load, Next List!''
Sun, 05 Jun 2022, 06:19
Pakz
Thats interesting. I could just generate a tile map in stead of the solar system.
Page : 1 2 3 4 5 6 7 8 9 10 11 12 13 Prev 14
Next