TomToad

Forum Replies Created

Viewing 15 posts - 16 through 30 (of 41 total)
  • Author
    Posts
  • in reply to: Can't use Color in Select/Case statement #10352

    TomToad
    Participant

    I see the problem now.  When the std.graphics.color module is compiled, an overloaded bbCompare() function is created.  In this function, the fields are compared 1×1 and result is returned.  This is what the If/Else/End statement is using to compare the two parameters.  If I overload the = operator, a function called m_eq() is created and this is used instead of bbCompare.

    Monkey2

    Compiles to C++

    Now the Select/Case statement is different.  Instead of using bbCompare(), it is using C++’s built in == operator.  Since Monkey2 has no way to overload C++’s == operator, it creates the error.

    monkey2

    Compiles to C++

    So the solution would be either 1) Have Select/Case use bbCompare instead of == or 2) be able to override == at the C++ level.

    in reply to: Can't use Color in Select/Case statement #10348

    TomToad
    Participant

    Your example has nothing to do with my problem.  [b]If currentColor = Color.White [/b] works just fine.  Succeeds when currentColor is white, fails on any other color.  The problem is not with If/Then, but with Select/Case, which won’t even compile.  Your example compiles fine, even though you don’t get the expected results.

    Also, floats are comparable.  The reason why your test fails is due to the tiny imprecision caused by storing floats.  Due to that imprecision, they are rarely exactly equal. Instead, you should subtract the two and compare against a tolerance.  If c-(a-b) < .001 gives the expected results in your example.

    in reply to: Change color in a sprite #10343

    TomToad
    Participant

    You could always keep a copy of the image in a pixmap, then you can alter the pixmap with pixmap.SetPixel() when you need to and use New Image(pixmap) to transfer the altered pixmap to an image for rendering

    in reply to: IDE options #10214

    TomToad
    Participant

    Maybe try out the different themes (window->themes). Going through them, I find a couple blurry, just assumed it is my bad eyes trying to focus on the different color combinations. Maybe it is just certain fonts can’t scale properly at certain resolutions.

    in reply to: Tiled #10012

    TomToad
    Participant

    Took a look at a simple json output from Tiled.

    The “layers” array is actually an array of objects. Each object contains info about each map layer. The “data” array within the layer object contains the actual map data.

    I wrote a little sample here that reads the data, stores it in an array, and prints the info. Not complete, but hopefully will help.

    Hmm, When I post the code here, I get a “Forbidden” error. well, you can grab the source here. https://drive.google.com/open?id=0B1zQ5dfVU3jbZGtjZmtCckx3SWM

    in reply to: invalid digit "x" in octal constant #9549

    TomToad
    Participant

    Not a bug. Using a leading 0 is how you type numbers in octal with Monkey2, just like typing a leading $ for hexadecimal. I guess you will need to use leading spaces instead

    in reply to: Properties example code pls? #9489

    TomToad
    Participant

    This example creates a vector class in which the vector can be stored as direction/magnitude, or as x/y. Internally, it is stored the same way so uses properties to convert between the two. This is handy as it allows you to change implementation behind the scenes without needing to change the interface as well.

    in reply to: Enum's type #9445

    TomToad
    Participant

    An Enum will compile to an opaque enum class in the c++ source which uses a signed int for its base. For some reason, M2’s Enum will not accept negative values. I think this might be a parser bug as I can do this

    And it works as expected. (much easier to understand than the $FFFFFFFF hack I posted earlier)

    in reply to: How to save a Image? #9390

    TomToad
    Participant

    Don’t know if this is the best way, but it works. MyImage is the image you wish to save, and savefile is the name of the png file to be saved.

    in reply to: How to resize multidimensional arrays? #9381

    TomToad
    Participant

    Two dimensional arrays cannot currently be resized. You need to roll your own function to do so. Here is an example function that works.

    in reply to: Enum's type #9359

    TomToad
    Participant

    You could cheat a bit and use twos compliment

    [/crayon]

    is equivalent to C++

    [/crayon]

    To find the twos compliment of a signed Int, you can use Print Hex(UInt(-1)) in Monkey2

    in reply to: lots of errors in both important tutorials #9290

    TomToad
    Participant

    I never understood the value in dynamic types.  Seems that it is unproductive to save a few seconds of typing int, float, etc.. when the result is hours of debugging headaches when you type myNum = 3 instead of myNum = 3.0

    As for null objects, it makes sense that you should create an instance with new controls before calling fortifyunit() method.  Without an instance, there is no fortifyunit() to call, only a definition.

    in reply to: Close New v1.1.05 #8984

    TomToad
    Participant

    I have the same problem.  Open Ted2go, start a new document, type Self. and just as soon as you hit the ., the IDE closes.  If you turn off autocomplete, the problem goes away (but you loose autocomplete)

     

    Edit: Just submitted an issue with the Ted2Go github site.

    in reply to: "+=" inconsistency. #8448

    TomToad
    Participant

    I get 11598408 for both on Windows 10.  I think it has to do with the Float to Int conversion done on the .1. If you use 0.1 instead or define y as a float, then you get correct results.

    in reply to: Convert int endian #8253

    TomToad
    Participant

    A class for swapping big/little endian from/to native format.  Just create an instance of the class and call endian.swapEndian(n:int, original:Int) where n is the number to convert and original is the byte order you are converting from/to.  Nice thing is, the same method is used in each case. pass the int you wish to save followed by the ByteOrder value you are saving to, or pass the value you just read followed by the stored  ByteOrder .

Viewing 15 posts - 16 through 30 (of 41 total)