Search ProofOfProgress Blog

Thursday, March 19, 2015

Custom Haxe Libs.

 Not sure what the answer is to get custom library code to work...
I just want to write a class...
But I think the clue lays in downloading haxeflixel and blit5 and looking at the
configuration files in their root directory.

//the clue is probably here:
 ///include.xml for blit5 library


I just want to make a damn class Haxe

I just want to make a class and import it into my project.
It has been over an hour of trouble shooting.

What I know:
1. Typical AS3 package conventions are not conventions in haxe, but rather rules.
To keep safe, keep all folders using only lowercase letters a-z.
All class names like MyClass.hx MUST start with capital letter.

Bad package structure:

Good package structure:

There seems to be some XML configuration that needs to happen as well...
As simply going into the project properties and adding "mylib" to your classpath
will not work.

The IDE will recognize it. But the compiler will not.
Something about a config file overriding whatever you do in those areas of the IDE.

I know you CANNOT use the IDE to configure haxe projects...
But what I exactly need to do, I am not sure.

I think it has to do with haxelib keywork inside of application.xml
And also having configuration files inside the root folder of your custom library folders.

Fuck this.
I don't want to deal with this kind of bullshit.
Haxe seems like a really good idea... But maybe it is time to learn straight c++?
And cut myself off from all these tech stack problems.

I mean, sure, I would still have a tech stack issue.
But lets not forget that haxe is built with C++ and C.

In the end... There is no magic tool if you have a very specific vision...

I need to think on this.

-John Mark

My Haxe Classes Not Found

Trying to figure out why I can't make my own class and import it in haxe.
So far I've found out this:

1. dont use upper cases, underscores, or numbers in your package folder names.
2. Possible that .hx file MUST start with a capital letter.

The parsing of packages is kind of weird, and you need to keep everything super simple...
Even with all of this... I Still don't have my stuff working just yet...
Will keep working on this, and cut/paste the links I've visited here.

//This is where I learned about the capitalization thing:

//A simple class definition example:

//About the import statement and resolution order:

//hmm... a manual add of the library?
//Could definitely be a case of "The IDE knows, but the compiler does not:"
  &lt name="openfl" />
  &gt name="task"/>

//hmm... that solution just led me to the error:
Could not find haxelib "hroot", does it need to be installed?

...So...I have to install libraries as well as include/import them?? WTF.

Hmm.. I remember something about adding your classes to the compiler options,
rather than to the class paths in haxe. Maybe that will lead me to the answer?

Maybe user classpath in the haxe context of the compiler options?
But I was told not to do that... That global class paths are a bad idea...
Hmm... Whatever...
I don't care about bad conventions right now.
Something working with a hack is better than nothing working with a "best" practice.

So, I think the problem is "compiler cant find my class haxe"
So, searching for that. Still having trouble. It has been about an hour of trouble shooting now.

Haxe seems like a really good idea.
But it is this kind of trouble shooting that makes me wonder if this is a stable platform that
will be around for a while.

Error: Could not find haxelib "hroot", does it need to be installed?

Hmm... looks like you may have to include a .json file at the root of your library?

//On: "you can't make good games in haxe" and blit5.

...Still can't find answer...
Maybe I should just give up and go to SDL and C++ and forget about all of the tech stack confusion of mobile? You know... Instead of focus on making a game on all of these different platforms... Just focus on making a good game for ONE platform?

Embed Assets in OpenFL NME Haxe

 In summary:
Inside file: main.hx:
import openfl.Assets;

Inside file: application.xml:
< assets path="assets/img" include="*" / >
the &lt and &gt is supposed to be less than and greater than symbols...
But the HTML editor wont let me escape them when I go into the source...

----------------------- Rants an other information below. ---------------------------------------
Found the answer.
Kind of angry at the fact that... What was lacking was an import.
What the hell?!

Maybe I am just a complete idiot.
But how about people start remembering to include the damn import statements with
their code examples!?

Answer here:

Extra notes:
This looks interesting:
 embed="true" path="Assets" rename="assets" include="*" exclude="openfl.svg" />


Wednesday, March 18, 2015

: Unknown identifier : Assets Haxe OpenFL

Having trouble with the global assets path in HAXE 3.0 / OPENFL.

Storing links here:

Getting message: : Unknown identifier : Assets

Instructions in openfl-readme.txt say:

    Place all your images, sounds, fonts in /assets and access them in your code using the
    global Assets class which abstracts assets management for all platforms:
        var img = new Bitmap(Assets.getBitmapData("assets/my-image.png"));
...Is... Parked?
Okay. One dead lead.

Mention of a .hxcpp_config.xml
File that needs to be configured. But only shows up when you target C++.
What is the C++ target? NEKO I am guessing?

More in the openfl-readme.txt:
- on mobile, Bitmap blitting is NOT performant,
    - use spritesheets and Tilesheet.drawTiles for optimal rendering performance.

"performant", never heard that word.

Okay... Need to pack up.
I'd like to make a simple Haxe App.
Because Haxe seems like an easier to work with tech stack than Android Studio.
Though I do like google and what they do.

-John Mark

Sunday, March 15, 2015

How to use std::logic_error for custom errors c++

If you are NOT using namespace std, it is a bit tricky:
//begin c++ file:
int main()

      throw std::logic_error("This is an error");

Tricky things to note:
1. We are NOT using the 'new' keyword here.
2. logic_error is in the std namespace... yet will not be recognized unless you #include
I find this weird because you don't need to #include if you are using namespace std.
However, using namespace std is a bad idea because of all the names it imports into the global namespace.

I rather like to be more specific with which names/tokens I want to use in my code.
For example:
using std::string
So I don't have to write std::string everywhere.

error: conversion from ‘std::vector<std::basic_string<char> >*’ to non-scalar type ‘std::vector<std::basic_string<char> >’ requested

Here is a post that helps with that on stack overflow:

So today I've been doing simple code-eval problems using C++.
I don't know much about C++.

I keep up finding solutions on closed threads on stack overflow that say:

closed as too localized by [name here]

"This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center."

And it makes be wonder...

Hmm... 1877views in 2 years?
I guess that isn't a lot. But how do they define "unlikely to help any future visitors?"
1877/ 2 = 938
938 / 365 = 2.5
So, at least 2 people are stumbling upon this every day.

IDK. I just find it odd that I find most of my solutions on threads that are closed for breaking some kind of rule. I find it hard to think my problems as a total noob are just so unique that I keep stumbling upon useful closed threads. Which makes me question how the site is moderated.

error: ‘logic_error’ is not a member of ‘std’

Closest matching post isn't very close:!topic/quickfast_users/vXq5xZH7rqo

/source.cpp: In function ‘int main(int, char**)’:
/source.cpp:52:23: error: ‘logic_error’ is not a member of ‘std’
                 throw std::logic_error("woah buddy");

Don't understand... Because I have the same line of code working in some other code of mine.
And all the examples say to write it the way I have:

throw std::logic_error("woah buddy");

"std::logic_error is thrown by a user C++ program logic intentionally. Predicted by a user program."
huntch that maybe #using <stdexcept> might help?

If you are not using namespace std, then you must
put #using in the top of your c++ file to get std::logic_error to work.

Which is weird to me. Because I included "std::" so shouldn't it work without any declarations?
I don't know what I am doing.

But. Trying to code without the "using namespace std" to avoid name collisions and other weird

errors that I hear can happen by importing a whole bunch of things you do not need into the global namespace.

Sunday, March 1, 2015

CodeEval ReadMore: Hardest Easy Problem Ever

I am going to save you the headache of this easy problem that took me about 4 hours to solve:

Here is the description:



You are given a text. Write a program which outputs its lines according to the following rules:
  1. If line length is ≤ 55 characters, print it without any changes.
  2. If the line length is > 55 characters, change it as follows:
    1. Trim the line to 40 characters.
    2. If there are spaces ‘ ’ in the resulting string, trim it once again to the last space (the space should be trimmed too).
    3. Add a string ‘... ’ to the end of the resulting string and print it.
Trim did not mean what I thought it meant. To me, trimming is removing white spaces.
Trimming to 40 characters to me would mean... line.substring(0,40); //(JAVA)

I was really confused at why non of the read-more example output stopped in the middle of a word.
Because of a bad example, I couldn't figure out if that was co-incidental or by design.

Example: With the input:
123456789 123456789 123456789 123 Supercalifragilisticexpialidocious
I was pretty sure due to the instructions, the proper output would be something like this:
123456789 123456789 123456789 123 Superc... Read More
But the correct answer is more like:
123456789 123456789 123456789 123   //Notice the absence of the sliced in half "Superc"

 So... What they are actually asking you to do is:
If the line is > 55 characters:
1. Tokenize the line using " " as a delimiter.
2. Build the string back up, stopping before you go over 40 characters.
3. If you get a zero-length string this way, just do line.substring.split(0,40);

I hope this helps someone.
Judging by everything I read on the internet.
I seem to be the only one who couldn't make sense of the instructions.
I really hate problems where the majority of why I can't solve it is because I don't know
what it is asking.

Today definitely re-affirms my grandfather's saying:
"A problem well stated is a problem half solved."