Mark Sibly

Forum Replies Created

Viewing 15 posts - 286 through 300 (of 1,431 total)
  • Author
    Posts
  • in reply to: Some notes about Pixmap #12112

    Mark Sibly
    Keymaster

    I think it uses some png compression by default thus artifacts.

    PNG uses loseless compression – if there are artifacts it’s a bug (possibly mine or STBs).

    in reply to: Playing with first class functions #12097

    Mark Sibly
    Keymaster

    Also I found that mx2cc allow us to write weird code:

    That *is* pretty weird, but it sort of makes sense (to me). I guess it’s a bit like x+=Null where x is an int. I can live with this wrinkle. All other results are what I’d expect (and what I think people would intuitively expect) anyway.

    in reply to: Emscripten sockets #12093

    Mark Sibly
    Keymaster

    So I don’t even know where to begin.

    Welcome to my world!

    Perhaps try and get a plain WebSocket javascript test app working with your server first? This would probably be my approach – make sure server is working before trying to get clients working, as at this point it’s not even known whether monkey2 sockets work with emscripten. I’d actually be surprised if there’s not some tinkering required, as there has been on EVERY os so far.

    in reply to: Playing with first class functions #12092

    Mark Sibly
    Keymaster

    GetValue <T>:T ( key:String,value:T=Null )

    I quite like this, but I thought your original point was that GetValue should *fail* if ‘key’ can’t be found? I actually like this idea. Perhaps we could have both, eg:

    In this case, it’d be possible to get exactly current behaviour by using ‘GetValue(key,Null)’ but it’d also pick up existing bugs where you expected something to be in a Map but it wasn’t.

    in reply to: Playing with first class functions #12090

    Mark Sibly
    Keymaster

    > There is an default (t) in c#

    This is pretty much ‘Null’ in monkey2, eg:

    should be about equivalent (as long as type of ‘T’ can be determined of course).

    This is largely why I made Null ‘context sensitive’ (again – it was in bmx, I goofed in monkey1) – so that generic methods etc. could ‘Return Null’ and so on without caring what type was being returned.

    Indeed, in monkey1 containers there is some awful code like:

    Just to get the same behaviour you can now get in monkey2 from ‘Return Null’! You learn more from your mistakes than your successes etc.

    in reply to: Emscripten sockets #12088

    Mark Sibly
    Keymaster

    Is there ANY way I can send and receive data over the internet using Emscripten?

    You will need to set up a server that handles the websocket protocol I believe. I have no idea how to to this myself, but according to this it may be possible to do in monkey2:

    https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_servers

    It doesn’t look *that* painful, although I wont be attempting myself anytime soon sorry. And getting it hosted is another issue altogether if you don’t want to run the host yourself. But if you do get something going I’d be happy to help if I can.

    in reply to: Playing with first class functions #12086

    Mark Sibly
    Keymaster

    If f1 returns 5 and f2 returns 10 then f1+f2 should return 15.

    Nothing is being invoked though and IMO, f+=f1 should ‘mean’ the same as f=f+f1, regardless of the types of f and f1.

    operator += is used as ‘subscription’ operator for a long time

    Bah! I hate this ‘reasoning’ for adopting something! To me, ‘+=’ only makes sense because it is possible to ‘add functions’ in the first place with ‘+’ (well, it’s supposed to be…). So there is no ‘subscription’ operator, there is just function addition and ‘+=’ is just an assignment shortcut like all the other forms of ‘+=’.

    in reply to: Playing with first class functions #12079

    Mark Sibly
    Keymaster

    Returning ‘null’-values of different types can be very insidious.

    You’re probably right, although it does allow the above ‘magic’ to work. Ditto other tricks like non-intrusive ref counting, eg: ‘_refs[obj]+=1’ will ‘just work’.

    I’m not really opposed to changing it so that [“blah”] where “blah” is not in the Map causes a runtime error instead. I doubt it’ll cause many/any problems in existing code, but it will break the code at the top you were initially so happy about! Will think about it…

    I feel like I still don’t take full advantage of first class functions, even though I understand how they work now

    I’m a bit the same way, still learning a lot of this stuff. I do think ‘signals’ (ie: ‘Field Changed:Void()’ style members) are often a way better way to go than virtual methods in many situations.

    Is it expected behaviour?

    Almost, you’re definitely supposed to be allowed to chain functions together, although ‘f=f+F2’ should work too, will fix!

    and passing by reference could be useful in some designs!

    I do have a safer ‘Var’ feature on an internal language features todo list…


    Mark Sibly
    Keymaster

    Actually, my idea is bollocks anyway, it’d just ‘pointilize’ everything.

    in reply to: Function Value for Setter #12061

    Mark Sibly
    Keymaster

    Nope, this cannot be done.

    in reply to: How to use Sprites? #12060

    Mark Sibly
    Keymaster

    Yeah, mojo3d bananas are really just ‘tests’ right now – ditto with mojo3d-loaders and mojo3d-physics.

    In fact, I’m trying to get into the habit of adding more tests to modules so it can pay to have a browse through the entire modules dir.

    in reply to: Playing with first class functions #12059

    Mark Sibly
    Keymaster

    Hopefully it all makes sense though – that is my goal!

    in reply to: Entity pitch/roll/yaw? #12057

    Mark Sibly
    Keymaster

    camera.Rotation = Null ‘ Entity.Rotation is not a thing. Boo!

    This should work! I just tested entity.Rotation by adding this at the top of OnRender in (very latest) ducks demo:

    _ducks[0].Rotation=Null also works here too…

    [edit]

    Maybe Rx / Ry / Rz extension properties are what you searching for.

    Bingo. Just went to add pitch, yaw, roll, and they’re already in there as Rx, Ry, Rz, LocalRx, LocalRy, LocalRz. I may add Pitch, Yaw, Roll equivalents too…will think about it.

    Also Vec3 struct have Yaw and Pitch properties, but suddenly haven’t Roll.

    Vec3 has never had roll – vectors in general can’t have roll as they are infinitely thin, ie: there is no ‘sideways’ *to* roll! Matrices can though as they really represent an entire ‘space’.

    in reply to: Playing with first class functions #12056

    Mark Sibly
    Keymaster

    Very cool!

    It’s like a magic – we don’t put value into Map

    The magic here is thanks to this code…

    …being converted by monkey2 to…

    For the first line, since the map doesn’t actually contain “walk”, a null value is returned by evt[“walk”].

    A null function value is a NOP function (ie: it doesn’t do anything and returns ‘null’) but is still a normal, valid function (just like a null int, ie: 0, is a normal int) and can therefore be used with ‘+’.

    The last line is what actually puts the value into the map – magic!


    Mark Sibly
    Keymaster

    Can’t think of anything off hand. Possibly a shader could be used to ‘snap’ vertices, but then you’d end up with a lot of overdraw and it would be likely to be considerably slower.

    I think the ‘draw stuff offscreen’ approach is pretty much the way HW expects things to be done these days. I have also recently found a ‘blit framebuffer’ GL extension that should make this even faster in some cases, not that I’ve ever found it to be too slow or anything so far.

Viewing 15 posts - 286 through 300 (of 1,431 total)