Hello World. , and basics: how to?

Monkey Forums/Monkey Programming/Hello World. , and basics: how to?

jhc(Posted 2015) [#1]
Hi Everybody, my name is Jin, and im new here.

a friend of mine told me about monkey X some days ago.

im just trying to do simple things like "hello world" and some mathematical things, but

i dont know how to do these correctly.

is there any book of "Monkey X" basics?

it has been very difficult to try the basics just seeying those "banana" examples. XD


therevills(Posted 2015) [#2]
Hello World using Mojo (the graphics/sound engine of MonkeyX):




jhc(Posted 2015) [#3]
thevills thanks so much.

but i this example is not working XD


TeaBoy(Posted 2015) [#4]
Hi Jin, Can you post your code on the forum?


ImmutableOctet(SKNG)(Posted 2015) [#5]
Alternatively, here's an example of outputting to the console:


Yeah, that's it. You don't even need half of what I wrote. The standard 'monkey' module is auto-imported, so you can use it automatically. The 'Print' command is in the 'monkey.lang' module.


therevills(Posted 2015) [#6]
this example is not working


Works fine here... what errors do you get?


MikeHart(Posted 2015) [#7]
The help docs of Monkey have a tutorial section. I recomment you study these. Also you should use the html5 target with a firefox or chrome browser in the beginning. To target other platforms, certain tools and sdks need to be installed, which can be a little difficult for a beginner.
I have written a book about Monkey before, but it is rather about developing games, than explaining the Monkey basics. The tutorials i have mentioned before do the job quite well.
.


ImmutableOctet(SKNG)(Posted 2015) [#8]
@jhc: I forgot to bring this up before, but that example therevills posted was pretty poorly slapped together. Most targets won't even render without proper update-rate initialization.

Here's a fixed example:


This will actually run. Also, the return-code from 'Main' should always be zero under normal circumstances. Also keep in mind that Monkey is not tethered to Mojo, it's just the primary framework, and it's what basically everyone uses.


MikeHart(Posted 2015) [#9]
therevills posted was pretty poorly slapped together.


Wow, what a statement.

Btw. your SetUpdateRate(60) statement is pretty old school these days. I would rather use

SetUpdateRate(0)



ImmutableOctet(SKNG)(Posted 2015) [#10]
@MikeHart: Most people develop games to run at specific rates, even if they're delta-timed and/or using some kind of fixed-rate scheme, so requesting the ideal framerate tends to be beneficial. Also, realize that my example was just that, an example. Just because there are different ways of doing something, that doesn't mean one way is always ideal. Personally, I'd agree that using an update-rate of zero isn't a bad idea, but at the same time, this is generally driver and system dependent. For example, on my system, and many other systems setting the update-rate to zero results in unlimited updating and rendering. This is seriously wasteful for simple examples like this, heck, even 60 FPS is utterly ridiculous. But since the vast majority of monitors run at 60, I thought it would be better for an example. It's not like the official examples are any different (Yes, I'm aware zero wasn't an option a while ago). And since the 'SetUpdateRate' command itself is already a request, and not a demand, I don't see giving an explicit update-rate as a bad thing. It's not like rendering should actually matter to a game-engine, to begin with. Mojo simply uses this as the assumed framerate. If I remember right, Mojo has some code to skip rendering when updating could be done quick enough, but the rendering step could not.

Also, it's pretty obvious therevills was trying to right something quick and to the point. My issue was that he didn't even bother to check if it worked or not. That, and he was using unneeded implicit casts to booleans, which were used in conditions where the return values were undefined, mind you. And, you know, returning 'True' on the 'Main' function, something which some systems see as an error code. Just as an example, the "stdlib.h"/"cstdlib" header(s) on Windows (As implemented by several versions of Visual C++) define 'EXIT_FAILURE' as 1, which is what he was effectively returning. If you're a Windows user, and you see a message to the effect of "Did this program work correctly for you?", that's the kind of behavior you can expect from the OS under certain circumstances. A new Monkey user should not make these mistakes.

If it wasn't obvious already, I'm the kind of person who makes his code as consistent as possible.


jhc(Posted 2015) [#11]
therevills: Sorry it was my mistake! and thank you again!

I copied only half of your example XD, didnt see the rest.

All examples worked. Thanks Very much to Everyone for helping!

Hey ImmutableOctet(SKNG):

When i saw all those lines just to write "Hello World" my reaction: O__o (but i thank you too, im gonna try to understand every command line to see what are those for, i mean all different examples you guys wrote here)

Monkey X is a different language for sure, and i decided to study this amazing tool. (seems to be more powerful than Gamemaker for games and applications) and faster.

now im going to go try some new commands! thanks again fellow!


Gerry Quinn(Posted 2015) [#12]
I think most people will use Monkey for graphic output such as games, so there has been no real interest in creating console-type examples. It still can be done as per the examples above.

Even if the examples are to do with graphics, you will still find examples of code (using arrays for example) in the methods.


Paul - Taiphoz(Posted 2015) [#13]
jhc search youtube for smalltimeoutlaws monkey tutorial videos its a perfect starting place and will start you at the ide and take you right through to more complex programming and object orientation.


Paul - Taiphoz(Posted 2015) [#14]
https://www.youtube.com/watch?v=13o2IRd56MQ&list=PL5506B358FC111CD8


therevills(Posted 2015) [#15]
but that example therevills posted was pretty poorly slapped together


Says Mr Wall-of-Text....

My issue was that he didn't even bother to check if it worked or not.


And how do you know I didnt... which I did and it works fine. Why didnt you test it before making your snarky comments?

that, and he was using unneeded implicit casts to booleans


I prefer readability, nothing wrong with the return types being True or False.

Maybe instead of writing walls of text, maybe try the code before you make stupid comments and think before you write anything.


skid(Posted 2015) [#16]
Omitting a call to SetUpdateRate in OnCreate causing OnRender to never fire use to be a feature of some targets versus others.

This might seem trivial but I think it is very important we remain vigilant and make removal of such discrepancies between the various targets a priority when they are detected.


ImmutableOctet(SKNG)(Posted 2015) [#17]
Your code didn't render on the GLFW3 target for me at all, which was a red flag to me. Also, I wasn't saying you're a bad programmer, just that you were being a bit lazy here. I think you're forgetting that this was supposed to be quick to begin with. The main problem I had was that it didn't even render for me, but it didn't help that you were going against the docs. I see now that this could have been related to Windows's display server screwing up, as it didn't display anything for me initially. Plus, I'm not too sure if Mojo technically guarantees that 'OnRender' will be called without an update-rate. And tell me again, how does the fact that I wrote more than you do anything but enforce my point even further? I don't hold people to the same standards as myself, first of all. But I expect at least some effort in the way of consistency (One of your methods doesn't even end the same way). Also, the official documentation says that for future compatibility, most, if not all of the "OnBlah" methods should return zero. It is not clear at all when there's two types ('Bool' and 'Int'), and you're throwing around implicit casts where it's unneeded. Also, your last remark of "Think before you write" completely contradicts your first argument, which itself was an argument with no basis.

Look, he wanted to start learning Monkey, and I think following standard practice if, for nothing else, the expected behavior for Mojo is the best course of action. Stylistic differences aside, the code you posted was lazily put together, and I seriously don't blame you for it. Considering you've made Diddy, which works great from what I've tried, I expected a more consistent example. That's it.


therevills(Posted 2015) [#18]
Omitting a call to SetUpdateRate in OnCreate causing OnRender to never fire use to be a feature of some targets versus others.

This was changed a few versions ago, it defaults to 0. If it doesnt its a bug in the other targets.

Your code didn't render on the GLFW3 target for me at all,

Again sounds like a bug in GLFW3.

just that you were being a bit lazy here

I'll tell you what... I wont bother replying to people, I've got other stuff to do.
Note to self: Don't feed them...


Paul - Taiphoz(Posted 2015) [#19]
Therevills you did no wrong, he's just being rude which you should simply Ignore, no longer posting help when you can hurts the new or old users and they didn't do anything to deserve that.

Your work, your help on this forum and in this community is valued mate, don't forget that.


jhc(Posted 2015) [#20]
Wow i forgot to use Youtube for some good examples and tutoriais, thanks for the tip Paul.

and Therevils, ImmutableOctet(SKNG)

thank you again guys!


RenK(Posted 2015) [#21]
jhc asks for simple Hello World examples and we jump to Mojo? And then snap at each other over the examples... Not a good first impression we are giving someone coming into this community.

Anyways, as Paul mentioned, the Small Time Outlaw's videos are the best "basics" tutorials right now, even if you aren't very experienced at programming in general. The end of the first Beginner video will take you through a Hello World example. While I've been learning his videos combined with Mike's book(Link) and the Documentation have been a great help :)


MikeHart(Posted 2015) [#22]
And then snap at each other over the examples


And I thought that was mandatory here in this community. :-))

jhc asks for simple Hello World examples and we jump to Mojo?


Imho, a beginner won't do much with Monkey without Mojo.


MikeHart(Posted 2015) [#23]
jhc, study the docs that ship with monkey. It is all there. Even the link to the videos that Paul has mentioned.


RenK(Posted 2015) [#24]
Imho, a beginner won't do much with Monkey without Mojo.


Just stuck me as a little sudden if all they want is a real basic hello world. That might just be me though, maybe i've been spending too much time toying around with having the console spit things out at me =P


therevills(Posted 2015) [#25]
he's just being rude which you should simply Ignore

Yeah your right Paul, I was in a bad mood too ;)

Your work, your help on this forum and in this community is valued mate, don't forget that.

Thank you :)

we jump to Mojo

Yes you can use the console target, but I would have guessed most people would want to use the graphics engine Mojo.