Forum Replies Created
-
AuthorPosts
-
Finally pinpointed the problem and boiled it down to this runnable example. Uncomment the final line to cause a linkage error.
Monkey1234567891011121314151617181920212223242526272829303132333435363738Class ThingMethod DoStuff() VirtualPrint "Doing Stuff"End MethodFunction DoStaticStuff() VirtualPrint "Doing Static Stuff"End FunctionFunction DoAbstractStuff() AbstractEnd ClassClass SubThing Extends ThingMethod DoStuff() OverridePrint "Doing Stuff in subclass"End MethodFunction DoStaticStuff() OverridePrint "Doing Static Stuff in subclass"End FunctionFunction DoAbstractStuff() OverridePrint "Doing Abstract Stuff in subclass"End FunctionEnd ClassFunction Main()Thing.DoStaticStuff() ' Prints Doing Static StuffLocal foo := New SubThing()foo.DoStuff() ' Prints Doing StuffThing.DoStaticStuff() ' Prints Doing Static StuffSubThing.DoStaticStuff() ' Prints Doing Static Stuff in subclassfoo.DoStaticStuff() ' Prints Doing Static Stuff in subclassSubThing.DoAbstractStuff()foo.DoAbstractStuff()Local bar:Thing = New SubThing()bar.DoStuff() ' Polymorphism doing its thing ; Prints Doing Stuff in subclass'bar.DoAbstractStuff() ' Causes linker error... Should polymorphism work for static methods?End FunctionShould polymorphism work on ‘static method’s / ‘class function’s?
Mark, what can I say? Thank you! I was expecting this to end up at the end of your probably-already-enormous-to-do list. But you had to go and implement it immediately! What were you thinking?? Now I have to find some time to try it out…
I’ve only ever used the text-based .fnt format that was supported by Monkey1 (and output by the littera online tool I linked to in the first post). Is this the same format as bmglyph? (no macos here). It got the job done but IIRC doesn’t support kerning. Kerning support would be great if it’s not too much work.
One major advantage of bitmap fonts is that (unless I’ve misunderstood something, which is quite possible) most font licences allow them to be distributed (more) freely as baked bitmaps but don’t allow you to distribute the TTF/OTF file with your app.
As a slight tangent to this thread, is anybody aware of a reliable way to detect physical device size?
I want to be able to vary white-space between buttons instead of just scaling the buttons to be a proportion of full-screen size. A button should be ‘finger-sized’ on any device, independant of the screen size.
Is this possible? And if it is, is it possible in a reliable way? I know it creates headaches for creating responsive web pages.
I haven’t really been following the shaders development in much detail but thought I might ask… are they now advanced enough to able to deal with FSAA?
That would probably work, too but I think it will still be a bit clumsy. I’ll keep playing around. I really need to stop getting hung up on programming constructs and actually get on with writing a game
@immutableoctet I agree it smells bad on the first sniff… but actually I think in this particular use case it makes sense.
I have an index (StringMap) of similar objects (all subtypes of a common base class). Inserting objects into the index is easy because subtypes automatically get ‘cast’ to their base class. Even then, I have some subtypes that require a bit of special treatment when added to the index, which I can do by overloading the Add() method. Most of the time, all members of this index can be called via virtual methods (indeed I often iterate over the list, calling the virtual methods).
But occasionally, I want to be able to use the extra (non-virtual) methods available in the subtypes from within more specialised code. This is rare enough that I don’t want to bump up that functionality into the base class.
In reality, all I am trying to do is save a little bit of typing during assignment :
Local thing:Derived
thing = Cast<Derived>(GetFromIndex(id))or
Local thing:Derived
thing = GetDerivedFromIndex(id)can be more succinctly written as :
Local thing:Derived
thing = GetFromIndex(id)But the latter requires an implicit cast (which I am trying to squeeze into an Operator To method).
Another way to look at it is that downcasting in an Operator To method when fetching items from the index seems to me to be a direct analogue to overloading the Add() methods for inserting items.
I think for now I am going to go the route of using GetDerivedFromIndex() methods, as this also allows me to do some type checking before doing a cast, which is not possible using an explicit cast.
Having just praised your error messages, I just typed :
Local a = 15
And got the error ‘Expecting end of line’, which seems a bit cryptic.
I’m sure it used to tell me I had missed out the variable type specifier (or := operator). Have I imagined that?
Sorry, I’ve gone off topic!
Getting a memory access violation was a surprise – you usually do a very thorough job, Mark, of catching this sort of thing at compile time and giving us useful, to-the-point error messages!
I agree, I could live without downcasting in Operator To, but I don’t see that as a reason not to ‘fix’ this ‘sort-of-bug’ if it is not too complicated (when you have 5 minutes to spare :). I could also live without ever doing any type casting at all… but one day I might wish it was availaible!
So for now, to make this work, I can do it like this :
Monkey1234Operator To:DerivThing()Local thing := SelfReturn Cast<DerivThing>(Cast<Void Ptr>(thing))End?
Actually, this also seems to work :
Monkey123Operator To:DerivThing()Return Cast<DerivThing>(Cast<Void Ptr>(Self))EndIs there any reason I shouldn’t use this?
I’m in the same boat as kheldar13 – I would love to have somewhere quick and easy to store some internal settings on android. High-scores, level state, parental controls, etc (in txt / json / csv format). I would also like these settings to be readable (and ideally writable if possible) by other apps.
Further into the future, I’d also like to be able to store images derived from cropped/edited photos taken on the device or from other sharing sources (whatsapp, downloads…) to allow custom images to be used in my app.
And immediately I will contradict myself – Danilo’s list will need ‘)’ and ‘]’ added to it for my first code example to make sense.
How exactly would ‘..’ work to solve the OP’s question, ie. to write a multiline string? The ‘..’ character would either end up in the string or you would also need to use ‘+ ..’ to concatenate each line, in which case there seems to be no need for the ‘..’ character since a line ending in a single ‘+’ is clearly intended to be a multiline expression (isn’t it?).
I, personally, would go with Danilo’s suggested list of characters. I can’t think of any others to add to his list.
I would however add one extra detail (don’t know how hard this would be to implement). Can the same list of characters be used at the beginning of a line to trigger a skip of the preceding line break? I like to write code like this:
Monkey12345678910111213Int thing := blah_function("really long string being passed to a function looks nicer in multiline layout",another_parameter)If condition = 5Or simon_says = "jump" ThenPrint "Jump"EndIflongstring := "First words"+ "then some more"+ "and that's all folks"I’m sure some of you will look at the above and go “yuk!”, but, well, you’d be wrong
@pepa, I can’t offer any advice about your lighting issue but am intrigued by your style of English. I am British, living in France so can sympathise with anybody trying to write in a second language. Do you mind me asking what is your native language? I hasten to add that your English is excellent and I have understood everything you have written apart from one thing :
The only thing I didn’t understand is what do you mean by ‘works but not’? Do you mean it compiles and runs but the output isn’t what you intended? Do you mean it mostly works but has a small glitch? Do you simply mean it doesn’t work?
Good luck finding the solution!
There is something lagging, somewhere. I tried to ignore it but it kept bugging me so I decided to try bypassing mojo and used a direct SDL call to get the mouse coordinates and… they are one frame ahead of mojo’s. Or at least, they are here, anyway. Attached is the code I used to test this and a screenshot of how it looks here. Can anybody else test this? Is it just my hardware or is it a mojo bug (I suspect the mojo bug atm).
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566#Import "<std>"#Import "<mojo>"#Import "<sdl2>"Using std..Using mojo..Using sdl2..Function Main()New AppInstanceNew MyWindowApp.Run()EndClass MyWindow Extends WindowPublicField slowness:Int = 200Field xsdl:Int, oxsdl:IntField ysdl:Int, oysdl:IntMethod New()ClearColor = Color.BlackSDL_CaptureMouse(SDL_TRUE)'SwapInterval = 1'Local timer := New Timer( 60, RequestRender )EndMethod OnKeyEvent( event:KeyEvent ) OverrideSelect event.TypeCase EventType.KeyDownIf event.Key = Key.Down Then slowness -= 10If event.Key = Key.Up Then slowness += 10If slowness < 0 Then slowness = 0EndEndMethod OnRender( canvas:Canvas ) Override'Plot mouse according to SDL_GetMouseState()canvas.Color = Color.RedSDL_GetMouseState(Varptr xsdl, Varptr ysdl)canvas.DrawLine(xsdl - 7, ysdl - 7, xsdl + 7, ysdl + 7)canvas.DrawLine(xsdl - 7, ysdl + 7, xsdl + 7, ysdl - 7)canvas.DrawLine(xsdl, ysdl, oxsdl, oysdl)canvas.DrawText("SDL Mouse: " + xsdl + ", " + ysdl + " [" + oxsdl + ", " + oysdl + "]", 10, 50)oxsdl = xsdloysdl = ysdl'Plot mouse according to Mojo Mouse.X and Mouse.Ycanvas.Color = Color.Whitecanvas.DrawLine(Mouse.X - 5, Mouse.Y - 5, Mouse.X + 5, Mouse.Y + 5)canvas.DrawLine(Mouse.X - 5, Mouse.Y + 5, Mouse.X + 5, Mouse.Y - 5)canvas.DrawText("MojoMouse: " + Mouse.X + ", " + Mouse.Y, 10, 70)canvas.DrawText("FPS:" + App.FPS, 10, 30)canvas.DrawText("Slowness: " + slowness + "ms (Use Up/Down keys to adjust)", 10, 10)Sleep(Float(slowness)/1000)RequestRender()End MethodEnd ClassAttachments:
Does anybody know if it is possible to get the mouse coordinates when the pointer is outside the app window?
-
AuthorPosts
