Monkey programming step by step blog (examples)

Monkey Archive Forums/Monkey Tutorials/Monkey programming step by step blog (examples)

Pakz(Posted 2014) [#1]
I made a blog where I am going to put code examples on. I made it today and have now put around 10 examples on it. The blog is meant for people to learn to make games with monkey by seeing/running/editing simple examples made up with things you need for games.

My java game code example blog has around 200 posts on it that I made in two years and I hope to get into Monkey and make a lot of examples for it to.

The link is :
The flash applets might be buggy if you have more then one of them on one page,

Here a link to a zip with all files from the blog and github.

Here is the link to the github page:

I also have a website where I can link to html5 versions of the examples. (Here I can use the html5 advantages over flash)

edit : (I wil try and add the new links to the list every now and then.)

Direct Links : (There is a Flash applet on each page showing what the code does. You might need to press the mouse a number of times on the applet for it to accept input.)

On my google+ ( ) a post is pushed every time a new example is created.

Getting started/beginners :
Monkey getting started - Adding up value through function example code
Monkey getting started - Printing Global variables Example code
Monkey getting started - Printing Constant variables example code
Monkey getting started - simple Rectangle Overlap example code
Monkey Getting started - Cls example code (clearing the screen with a color)
Monkey getting started - Drawing a red rectangle which moves code example
Monkey getting started - Random rectangles using for loop example code
Monkey getting started - Drawing and updating a 2d starfield code example
Monkey getting started - Setting up and drawing a tilemap code example
Monkey-X - Beginners - Moving a oval towards the mouse pointer Cos/Sin - code example
Monkey-X beginners- Moving/turning towards mouse cos/sin/atan2 - code example
Monkey-X beginners - Line Seperation example code.
Monkey-X - Beginners - Readpixels/WritePixels example
Monkey-X - Beginners - Array Resize - code example.
Monkey-X - Beginners - Array Length - code example.
Monkey 2d topdown moving the player with the cursor keys code example
Monkey - Drawing a rectangle below the mouse pointer code example.
Monkey - Player Class and drawing player class variables to the screen code example.
Monkey - Asteroid field with Class and List code example.
Monkey-X - String Slicing [0..4] (mid$) code Example
Monkey-X - Stack Pop and Push and Length and IsEmpty code example
Monkey-X - Millisecs, Width, Height and Date code example
Monkey-X - Draw Boxed Rectangle Code Example
Monkey-X - DrawPoly and DrawPoly using array code example
Monkey-X - WritePixel argb function and CreateImage code Example
Monkey-X - CreateImage, MidHandle, DrawImage scale and rotation code example
Monkey-X - Creating Images, writing pixels using Hex values code example
Monkey-X - Returning arrays from functions code example
Monkey-X - Empty Code Template
Monkey-X - Slopes (left/right down) Collision code example
Monkey-X - Drawing in Images(WritePixels) in real time - code example
Monkey-X - Matrix/SetAlpha/Rotate/Translate Effect - code example
Monkey-X - Center of Mass - code example
Monkey-X - Beginners - Rectangle Class and Fields - code example
Monkey-X - Putting/Calling functions in/from Classes - code example
Monkey-X - Beginners - Chaining and Classes and Self - code example
Monkey-X - Different sized (scaled) text - code example
Monkey-X - Lists in arrays - code example
Monkey-X - Lists in List - code example
Monkey-X - Beginners - Player firing bullet at enemy - code example
Monkey-X - Beginners - String position and FromChar - code example
Monkey-X - Beginners - List Count - code example
Monkey-X - Error command example
Monkey-X - RPG - Beginners - Making requesters code example
Monkey-X - Topdown Auto move and cursor keys - code example
Monkey-X - Beginners - Bouncing of the side and control - code example
Monkey-X - Beginners - Diagional bouncing and control - code example
Monkey-X - Beginners - Using/creating a Bool variable - code example
Monkey-X - Beginners - Using Rnd with a Bool Variable - code example
Monkey-X - Beginners - DeviceWidth and DeviceHeight - Example
Monkey-X - Beginners - Center text on screen (DrawText/DeviceWidth/DeviceHeight) - example
Monkey-X - Beginners - KeyHit(const) - example
Monkey-X - Beginners - KeyDown(Const) - example
Monkey-X - GetDate Seconds to Rnd Seed - code example
Monkey-X - TextWidth/DrawText/DeviceWidth - code example
MonkeyX - Wait/Busy animation - code example
Monkey-X - Making Image from 16 col Pallette - code example
Monkey-X - Point in Triangle 2D - code example
Monkey-X - Beginners - SetScissor - code example
Monkey-X - Beginners - Sorting StringLists - code example
Monkey-X - Beginners - Sorting IntLists - code example
Monkey-X - Getting started - Class setup - example
Monkey-X - Getting started - Class in List - updating and drawing - code example
Monkey-X - Beginners - Tinting a color - code example
Monkey-X - Beginners - DebugLog and DebugStop - code example
Monkey-X - Beginners - Error - code example
Monkey-X - Beginners - Strings - Contains - code example
Monkey-X - Beginners - String - ToUpper and ToLower - code example
Monkey-X - Beginners - String - StartsWith and EndsWith - code example
Monkey-X - Beginners - String - Replace - code example
Monkey-X - Beginners - String - Split - code example
Monkey-X - Beginners - String - ToChars - code example
Monkey-X - Beginners - String - FromChar - code example
Monkey-X - Beginners - Block Commenting #Rem - code example
Monkey-X - Rectangle Collision Helper - code example
Monkey-X - Beginners - Select and Default - code example
Monkey-X - Getting Started - Exit - code example
Monkey-X - Getting Started - Default Parameters - code example
Monkey-X - Beginners - Dot Product Helper - code example
Monkey-X - Beginners - Vectors Helper - code example
Monkey-X - Beginners - Vector Addition Helper - code example
Monkey-X - Beginners - Vector Subtraction Helper - code example
Monkey-X - Beginners - Vector Multiply Helper - code example
Monkey-X - Beginners - Vector Division Helper - code example
Monkey-X - Beginners - Vector Length Helper - code example
Monkey-X - Beginners - Unit Vector Helper - code example
Monkey-X - Beginners - Vector Rotation Helper - code example
Monkey-X - Beginners - Vector Projection Helper - code example

More difficult :
Monkey - 2D Player jumping code example
Monkey - CircleOverlap x1,y1,r1,x2,y2,r2 function code example
Monkey-x - Space Invaders Moving Alien wave code example
Monkey-X - 2d Fireworks using Lists code example
Monkey-X - 2D Sidescrolling map code Example.
Monkey-X - Creating and drawing an image from array code example
Monkey-X - Simple Topdown 2d Shooter code example
Monkey-X - Setting up and using multidimensional arrays (map[x][y]) - tilemap code example
Monkey-X - Platformer movement/player>map collision/player gravity code example
Monkey-X - Menu screen code example
Monkey-X - Topdown Tilemap with player movement code example
Monkey-X - Simple Cancel/Ok Requester code example
Monkey-X - Tilemap/Slopes/Player movement code example
Monkey-X - Platformer Game part - The Swinging ball - code example
Monkey-X - Platformer Moving Spikes code example
Monkey-X - Part of Defender game - Mountains/Flying - code example
Monkey-X - Random Terrain/Land Generator - Code example
Monkey-X - circlerectcollide collision function code example
Monkey-X - Another Circle to Rectangle Collision Function code example
Monkey-X - 2d Scrolling platformer with player and springy's - code example
Monkey-X - 2d Sidescrolling platformer with ai and bumpblocks - code example
Monkey-X - Simple 2d top down shooter with simple evading/following ai - code example
Monkey-X - Minimap and Map code example
Monkey-X - Basic space ship controls and scrolling (Matrix/Translate/Rotate) - code example
Monkey-X - 2d Platformer/tilemap jumping on ai - code example
Monkey-X - simple 2d top down space asteroid mining ai - code example
Monkey-X - Map tiles nearest to water highlighted - code example
Monkey-X - Organic behaviour with bots (repulsing) - code example
Monkey-x - Water surface counter (bug in older civ games) - code example
Monkey-X - Isometric map mouse/tile collision - code example.
Monkey-X - Roaming/Wandering ai which ray casts - code example
Monkey-X - Random obstacle avoidance - code example
Monkey-X - Beginners - Vectors code example 1
Monkey-X - Beginners - Vectors code example 2
Monkey-X - Beginners - Vectors code example 3
Monkey-X - Beginners - Vectors code example 4 (space ship method A)
Monkey-X - Beginners - Vectors code example 5 (space ship method B)
Monkey-X - Balanced 2d maps - code example
Monkey-X - TileMap inside a Class - code example
Monkey-X - 2d platformer Machine gun - code example
Monkey-X - 2d Platformer Flame thrower - code example
Monkey-X - Platformer Shotgun shooting - code example
Monkey-X - Simple single screen map editor - code example
Monkey-X - 3 dimensional arrays and Length - code example
Monkey-X - Fade in and Fade out - code example
Monkey-X - Screenwipe in and out - code example
Monkey-X - Shitting hamster algorithm - code example
Monkey-X - Mouse/screen Effect - code example
Monkey-X - 2d Block Pushing - code example
Monkey-X - Screen Wipe method 3 - code example
Monkey-X - Simple RPG Shop screen - code example
Monkey-X - Basic List view/selector - code example
Monkey-X - simple gui Tabber - code example
Part of RPG (Earth bound) battle screen - code example
Monkey-X - RPG Attack/Defence code example
Monkey-X - Rpg - Player fighting a enemy - code example
Monkey-X - Rpg - Leveling with XP - code example
Monkey-X - RPG - Beginners - Selector with 3 options - code example
Monkey-X - Random room placement map creator - example code
Monkey-X - RPG - Dungeon with monsters - code example
Monkey-X - inloop class creation and creating 2 dim array (meth) - code example
MonkeyX - Shooter with big destructable enemy - code example
MonkeyX - Line Collision/Overlap/Intersection - code example
Monkey-X - Moving Copper bars (rainbow effect) (demo) - code Example
Monkey-X - Copper Bars, Classes and Lists - code example
Monkey-X - 2d topdown Targeting aiming ahead - code example
Monkey-X - BreadCrumb artificial Intelligence - code example
Monkey-X - Simple Group Movement - code example
Monkey-X - Simple Pattern Movement - code example
Monkey-X - Rotating Astroids Image Array Class - code example
Monkey-X - Zombies throwing body parts 2d - Code Example
Monkey-X - Smarter group movement 2d - Code Example
Monkey-X - Platformer jumping and double jumping - code example
Monkey-X - GUI - Simple Vertical Slider (Color select) - Code Example
Monkey-X - Filled Balls, WritePixels/CreateImage/Class - code example
MonkeyX - Sideview Mining Map Generator - code example
MonkeyX - 2d Line Explosion Effect - code example
MonkeyX - Space Game Make/Rotate Poly and Cos Sin - code example
MonkeyX - Space game Ship/Map/Scrolling - code example
MonkeyX - Space Game Ship/Shooting/rotation - code example
MonkeyX - Heightmap/Texture/Image Generator - code example
MonkeyX - Map Island Dungeon Generator exp. - code example
MonkeyX - Tunneling and Rooms map generator - code example
Monkey-X - Red Clouds (drunken walk) - code example
Monkey-X - Tinting a Image using pixmap - code example
Monkey-X - Effect on Image (Hugi/Shade) - code example
Monkey-X - Texture by Smoothing (Hugi art.) - code example
Monkey-X - SinePlasma on Image (Hugi art.)- code example
Monkey-X - Speedtest with pixel pushing - code example
Monkey-X - 2d map and player infront-behind trees - code example
Monkey-X - Spreading 2 colors into palette - code example
Monkey-X - Make rainbow Image with random noise - code example
Monkey-X - Smoothed noisy rainbow from pallete - code example
Monkey-X - Example - Recursive Backtracking 2d Maze - code example
Monkey-X - Example - Additive Particle Flames - code example
Monkey-X - Midpoint Division Algorithm - code example
Monkey-X - Cos and Sin fun 01 - code example
Monkey-X - Flood Fill (seed fill) and Distance - code example
Monkey-X - Hollyday Greetings Screen - code example
Monkey-X - Roguelike Maps - code example
Monkey-X - Floodfill map distance - code example
Monkey-X - Circle Packing - Code Example
Monkey-X - Hill Algorithm - code example
Monkey-X - Particle Attraction - code example
Monkey-X - Path Following - code example
Monkey-X - Collision - Rectangle vs Rectangle - code example
Monkey-X - Collision - Circle vs Circle - code example
Monkey-X - Collision - Point vs Point - code example
Monkey-X - Collision - Line vs Line - code example
Monkey-X - Collision - Line Segment vs Line Segment - code example
Monkey-X - Collision - Circle vs Point - code example
Monkey-X - Collision - Circle vs Line - code example
Monkey-X - Collision - Circle vs Line Segment - code example
Monkey-X - Collision - Circle vs Rectangle - code example
Monkey-X - Collision - Circle vs Oriented Rectangle - code example
Monkey-X - Collision - Point vs Rectangle - code example
Monkey-X - Collision - Rectangle vs Line - code example
Monkey-X - Collision - Rectangle vs Line Segment - code example
Monkey -X - Collision - Point vs Oriented Rectangle - code example
Monkey-X - Collision - Line vs Line Segment - code example
Monkey-X - Collision - Line vs Oriented Rectangle - code example
Monkey-X - Maze - Binary Tree - code example
Monkey-X - Maze - Sidewinder Algorithm - code example
Monkey-X - Maze - Aldous-Broder - code example
Monkey-X - Maze - Wilsons Algorithm - code example
Monkey-X - Maze - Hunt and Kill Algorithm - code example
Monkey-X - Maze - Recursive Backtracker - code example
Monkey-X - Maze - Randomized Kruskals Algorithm - code example
Monkey-X - Maze - Simplified Prim's Algorithm - code example
Monkey-X - Maze - True Prim's Algorithm - code example
Monkey-X - Maze - Growing Tree Algorithm - code example
Monkey-X - Maze - Recursive Division Algorithm - code example
Monkey-X - Maze - Recursive Division with Rooms - code example

Difficult :
Monkey-X - Blocks color matching Puzzle game code example
Monkey-X - Platformer with roaming ai code example
Monkey-X - Topdown Scrolling RPG keys/coins/doors code example
Monkey-X - Basic Block Pushing game code example.
Monkey-X - 2d sideview flying with plane - code example.
Monkey-X - A-Star Pathfinding code example (A*)
Monkey-X - Cellular Automata code example
Monkey-X - Simple Pang game remake - code example
Monkey-X - Simple 2d Beat em Up - code example
Monkey-X - Cybernoid 2, 3 screens remade - code example
Monkey-X - RTS grouped units out of the way pushing - code example
Monkey-X - 1 to 5 room 2d Dungeon generator - code example
Monkey-X - 2d Dungeon Generator (small to large maps) code example
Monkey-X - Landmass/Islands floodfill numberer - code example
Monkey-X - Top Down 2d Racing game ai code example
Monkey-X - 2d Ray Casting on small map - code example
Monkey-X - 2d Maps with shore tiles system - code example
Monkey-X - Rotating platforms and player - code example
Monkey-X - Scrolling Platformer with climbing vines - code example
Monkey-X - Scrolling platformer with vines big level - code example.
Monkey-X - Map generator (zones) - code example
Monkey-X - Platformer with Elevators - code example
Monkey-X - RPG - Simple Inventory screen like diablo - code example
Monkey-X - RPG - Battle screen (4x*4x) - code example
Monkey-X - A*(astar) and heighmap random map generator - code example
Monkey-X - 2d topdown scrolling rpg with random maps - code example
Monkey-X - Bresenham's Line Algorithm - (function) - code example
Monkey-X - FLoodFill Pathfinding moving mobs - code example
Monkey-X - Platformer with WallCrawler(wall followingz) - Code Example
Monkey-X - 2d Map Generator (Mazelike) - code example
Monkey-X - RPG - Scrolling platformer - Mining.- Game Template
Monkey-X - Sidefilling Heightmap method - Code Example
Monkey-X - Another Map generator (failed maze generator) - code example
Monkey-X - Maze Generator - code example
MonkeyX - Tunneling/Rooms/Blurring map generator - code example
Monkey-X - Grey Background Image Generator - code example
Monkey-X - 2d topdown shooter - Between Space - code example
Monkey-X - Random Colored Textures - code example
Monkey-X - Random Maze and Random Cave tiles - code example
Monkey-X - Roguelike Explorer - code example
Monkey-X - RTS - Floodfill or Seedfill group pathfinding - code example
Monkey-X - Wall Tracing on Random Maps - code example

Sammy(Posted 2014) [#2]
Very nice indeed, all your examples are the perfect size for a beginner IMHO, well done! :)

samowitsch(Posted 2014) [#3]

golomp(Posted 2014) [#4]

Duke87(Posted 2014) [#5]

Pakz(Posted 2015) [#6]
I am now nearing 50 posts on the Monkey-X game programming step by step blog. In the few weeks that I have had the blog I have had around 700 pageviews.

Though I am finding it difficult sometimes to come up with things to make for it. But I have played a lot of games since the 80's and sometimes remember things that I want to make myself. I also get ideas from watching 2d games on youtube.

I use the search function in this forum frequently to look up how to do certain things and to learn new things. There's a lot of code in this forum but a lot I do not understand yet. But I will spend more hours reading through it.

I am beginning to like Monkey-X. I have gotten close to buying it already a few times. But I want to make sure that I stay using it so I will wait a little bit longer.

degac(Posted 2015) [#7]
Well,if you are a 'newbee' to MonkeyX, posting more than 50 source examples seems the perfect evidence of the 'easy' of the language itself!
I get my 'programming-mood' back just at the start of the year, so finding your blog was an unrefusable invite! So keep on!

I suspect that sooner or later you would to run some of the examples on an Android device...

ps: for your blog, I suggest to classify (if possible) every single example (basic, beginner, gfx code, etc) so searching a special things will become easy. Moreover a 'boxing' code would be nice (a page full of source code is not of great interest!)

skape(Posted 2015) [#8]
Turning into a nice code / example repository Pakz! Good work! :)

golomp(Posted 2015) [#9]
Good work Pakz !
Continue like you do.
Thank you

rebelas(Posted 2015) [#10]
Sometime I use Monkey (as well as BlitzMax) for small projects using glfw. I am not expert in it, however, I found Monkey to be a great programming language, fitting my One Hardware->One OS(C/C++)->One BASIC app layer philosophy. Your tutorial is a great contribution. I hope Monkey experts add more libraries to this language. Buying Monkey also contributes to the language.

Pakz(Posted 2015) [#11]
I have now 70+ posts with code on my blog. Things have been slowing down but I am still working with Monkey.

I figured out how to compile to flash and I found how to put the applets on the blog. Input does not work so I went through the older posts that did not require input and put the flash applets there.

Since getting into Monkey I spend more time programming so I decided to invest in my skills so I have ordered 4 programming books to learn about ai game programming so I hope to start making better ai things in the future.

Pakz(Posted 2015) [#12]
It turned out that sometimes you need to press the flash applets a number of times for it to activate(cpu?). So this means that input can be used. I have started putting the flash applet from the code in each post. This will take a while since I have almost 90 code posts already :)

MikeHart(Posted 2015) [#13]
Btw. why didn't you post the code examples here in the forum? I could have understood the usage of the blog if you had turned them into separate tutorials where you explain the code line by line. But for just a code collection, I think the forum here would be better and it would have a better reach. What was your motivation to use a blog instead?

Pakz(Posted 2015) [#14]
for me:blogs are a hobby, it has statistics :) (I like to stare at that and tell my parent about which countries people visit from and how many!), has applets!, ease of use(full screen edit (html and text)), the search option in the dashboard ( I often search and copy and paste my code into monkey, is easier then a file requester), the layout, the potential add revenue :), it is integrated with social media, getting experience with blogging, friends and family can easily find it. Could also be linked on my c.v.

I also do not want to put the simple things on this forum(spamming), unless I make a whole beginner post with different code and explenations and such. When I make something better then I put it in the code forum here. I am still learning the in's and out's of monkey.

But I was thinking of creating links to every post from my blog and put them in this thread. Like invader jim has on his post. (With beginner/starter sections)

With blitz basic I did put code on the code archives, but I did not put simpler things there.. Monkey also has no worklog, I liked to do that to. Blogging is more like that.

I have a disability income so I do not have to work so I do this to fill my days. Better than watching the television/radio or playing games :)

With my blogging experience already I have tought my mother how to make her own poetry blog. She only used to share them with friends. She also is interested in the statistics. And as it is for me it is also a online backup option.

So, that must be it :)

MikeHart(Posted 2015) [#15]
Thanks, I was just curious. It makes perfectly sense in your case. Keep up the great work. For sure it can spread the word about the tool.

MikeHart(Posted 2015) [#16]
Monkey also has no worklog

You could use the Monkey projects forum for that, I guess.

Pakz(Posted 2015) [#17]

Monkey also has no worklog
You could use the Monkey projects forum for that, I guess.

Yeah!, I had not thought of that yet :) I will start one for my strategy game project.

I have now also put some links to posts in the first post in this thread. Will make a bigger list soon.

Pakz(Posted 2015) [#18]
I put links to every blog post I have now.

vic(Posted 2015) [#19]
Thanks Pakz, great work :)

bazmonkey(Posted 2015) [#20]
Only just seen this. Excellent work.

garyk1968(Posted 2015) [#21]
Some great work although I notice on Chrome it often gets stuck as I guess you have too many apps on the same blog page.

Keep it up though!

Pakz(Posted 2015) [#22]
I am in a non programming phase the last two months. Though I made around 120 examples in the first 3 months that I started in monkey. I just noticed that I have had more than 6000 pageviews since I started the blog 5 months ago. I wil probably start a monkey2 blog when it gets useable.

The biggest problem with monkey I have is that the flash programs are buggy when there are more on a blogger page. I suggesti you to load them one at a time. The list in the first post here is up to date and loads one at a time.

I do not know when I Will get back into the zone. I recently got one of those movie and series on demand accounts and there is so much hours of good things there to see. Also smart tv that I recently got is sucking potential productive time away. Before all of that modern tv I almost never liked tv but I am impressed with what it is now.

Simonsuuri(Posted 2015) [#23]
This is really awesome tutorial set!

k.o.g.(Posted 2015) [#24]
Good work!

Neuro(Posted 2015) [#25]
Woah...i just saw this! Nice work on all of this, will definitely come in useful :).

Hotshot(Posted 2015) [#26]
Mind Blowing Code Examples to learn from!

Well Done :)

Pakz(Posted 2015) [#27]
Been doing RPG/Roguelike code examples. Count now close to 140 posts total on the blog with code and flash. More then 8000 pageviews in under 8 months :)

The direct link list in the first post is up to date as of this post.

Pakz(Posted 2015) [#28]
The blog passed 10.000 pageviews. I almost have 160 posts with flash and code on it now. It is hard to find things to make for it.

I still have to put links of the last posts to the first post here inthis thread. I mAde 4 today. Will add them later here and on the site.

I think i can get to 200 posts this year.

I get almost no traffic from google itself. My java code blog gets lots of hits from it. But java has many more users. One java post got about 2000 views. I have not had a really good monkey post yet.

If there is anything you would like to see made then post it here. I am no guru though so dont ask for elite skill things :)

Soap(Posted 2015) [#29]
Your work is good for the community!

As more hits are made with monkey, the higher chance it will gain more usage. Java has a much longer history, with titans of industry behind it.

Paul - Taiphoz(Posted 2015) [#30]
if your still looking for ideas on things to do you could just take a look through this forum and the blitz3d forums for posts like "How do I do bleh!" and then code that, you can bet if its something some one has taken the time to ask about, then there are plenty of others out there also wondering but that have not taken the time to ask.

Qube(Posted 2015) [#31]
Wow!, excellent code examples, thanks. I've just got around to looking into Monkey ( bought it on the day or release would you believe ) and these are great to learn from.

If there is anything you would like to see made then post it here. I am no guru though so dont ask for elite skill things :)

Mojo2 examples

kmac(Posted 2015) [#32]
A few of these don`t appear to compile with 84E. For example,

Or, is it just me.

Pakz(Posted 2015) [#33]
Are you sure you included the import line?

kmac(Posted 2015) [#34] ran with a stock installation of Monkey (86a) while the failure was on a Monkey X Studio installation. The fault is mine.

Pakz(Posted 2016) [#35]
I updated the list. There were a number of posts not listed for a number of months.

Today I made a Mining level map generator. It is modified older published code. Flash/code link Listed in the More difficult section on the first thread..

Pakz(Posted 2016) [#36]
I put a link (right top side blog) to the Monkey Online Build/Run site from ImmutableOctet(SKNG)

I think most if not all of the code wil compile and run if you copy paste it to the build site.

Pakz(Posted 2016) [#37]
I added more on the list above... The blog dashboard says I have 184 posts. Maybe I will reach 200 posts this month. I still have not touched Mojo2 though.

I just tried programming Monkey-X on the ipad mini in chrome. Not to sure if typing like that is good.

[ Code/Compile Monkey on : ]

RedGTurtlepa(Posted 2016) [#38]
hey, thanks again for the tutorials,
but I am about to attempt to recreate this game in Monkey (atleast the falling gravity pixels part)

you already have a extensive list of experience working with Monkey and mojo 1, so I was wondering if you dont mind me asking, Do you think its even possible just using the pixelarrays alone on loaded img data?

Also, do you have any tutorials for coloring greyscale sprites?

Pakz(Posted 2016) [#39]
I have not used the loadimage command yet. No idea if you can access the pixels when loaded. I remember someone writing he needed to load the image as data seperatly.

Making a game like vortex command ( I watched an hour or so) requires experience. But I bet it can be done in MonkeyX, it is a complex programming language. I would find it difficult though on my own at my current level. But I do not see anything that can not be done. (in the action part anyways) The game graphics if they are procedural I would not be able to make. Drawing graphics and animating is not my best skill either.

I am in the process of reading through the Hugi magazine programming articles. There are articles on textures and graphics ect. (formula's) that I want to read and would want to create something for the blog for. There probably are lots of formula's for coloring out there. Not to sure what you mean by coloring greyscale? (r,g,b)

RedGTurtlepa(Posted 2016) [#40]
oh I was asking for like r,g,b but more like tinting.

Pakz(Posted 2016) [#41]
I wil try to make some time to make a number of examples on how to change colors in the pixelsarrays.

Not so hard though.

Greyscale is add all three r,g,b up and divide by three and put that value in r,g,b.
Lighten is add r,g,b each with the percentage (255/100) iirc
Darken is the other way around.
I wil look at the tint and naybe other formula's and make simple examples of them.

Pakz(Posted 2016) [#42]
Here is the tint example :

Not on the list yet.

Pakz(Posted 2016) [#43]
I copied and pasted the code into github. There is a download as zip option for everyone I think. I wil try to keep the github and blog as synchornised as possible.

Pakz(Posted 2016) [#44]
Just passed 20.000 pageviews. First post added on 14 dec 2014. 197 posts total. Last month more then 1400 pageviews.

I already started a monkey2 git page. Not to sure if I am going to create a blog for that to.

RedGTurtlepa(Posted 2016) [#45]
How do you make your own scrollable camera from scratch? render objects relative to a Rect object? or set of coordinates? there is no viewport class.

Pakz(Posted 2016) [#46]
I always draw the things that are visible in the screen. What is visible in a tilemap or what is visible in space.

To move the camera with a tilemap i change the coordinat s of the mapx and mapy variables. Left is minus -1 on the mapx variable. The tiles that become visible then get drawn to the screen.

Look up tilemap tutorials on google or look on the examples on my blog that have maps. (Scrolling tilemap)

Drawing a screen of gametiles get done by

For y to screenareaheight
For x to screenareawidth
Drawtile map[x+mapx][y+mapy],x,y

With open space games i only draw the ships and planets and asteroids ect if the appear on the visible screen.

This always s ems to do the trick.

I might do a couple of more basic examples on the subject later today.

RedGTurtlepa(Posted 2016) [#47]
Hrmmm, yeah I dont really get what you did there

Gerry Quinn(Posted 2016) [#48]
Make your own ViewPort class, or equivalent, I guess. Something that has methods that tell you whether a given object needs to be drawn this frame based on its position and the camera position, however you implement them.

For a tiled map with numerous small objects in fixed or semi-fixed spatial locations, like your typical isometric game, you might just find a rectangular region that covers the viewing area, and draw everything in that, like you'd do with a 2D game.

MonkeyPlotter(Posted 2016) [#49]
Great examples to learn from , thanks for sharing ;)

HeliFly(Posted 2017) [#50]
Great work! Thank you

Pakz(Posted 2017) [#51]
I am still working on adding examples. Getting close to 240 examples.

31000 pageviews since the blog started.

I wil be getting a book on game 2d collision detection soon and if I understand the code and theory in the book then I will be adding a number of examples on collision and vectors. The book said it was for beginners :)

dubbsta(Posted February) [#52]
Pakz thats awesome! if i could make a few suggestions. The file names are really long and have characters that dont allow to run, the other night i was editing names for about 20 mins and then the next day the names reverted somehow...arrrrggg i wanted to pull my hair out lol. can all file names be changed with code to remove or replace characters? the other thing is variable names, can the be more meaningful for the sake of a noob :) or some explanation. just a request so we get the most out of your efforts with less struggle. And thanks for your contributions!

Pakz(Posted February) [#53]
I wil take a look at the filename issue. I never load them myself since i just copy and paste the code into ted myself.

I think i wil make a program that renames every file to a legal filename. You would need to run this file in monkey and it would rename every file in the directory. The structure in github atm is the title of the blog post.

I hope by removing the text monkey-x and replacing the " " ( space) with underscore "_" wil be enough.

I wil start to explain (comment) variable names when i create them.

dubbsta(Posted February) [#54]
good news! fyi 1 or more files have () in it.

Pakz(Posted February) [#55]
I made a codefile that asks for a directory and then it modifies the filenames.

Select the directory where the pakz examples files are in.

Here the direct link to it :

dubbsta(Posted February) [#56]
sorry not sure where to put file directory

Pakz(Posted February) [#57]
If you have downloaded the github zip file (what I think you ment) and have unzipped it then you need to select this directory(location on the disk) to modify the files.

dubbsta(Posted February) [#58]
i didnt see a zip, i copied and pasted and saved then ran and i get an error native file system not implemented

Pakz(Posted February) [#59]
Do you have a mac?

The zip download should be here :

dubbsta(Posted February) [#60]
no when i click the link i dont get green link(clone/download)

Pakz(Posted February) [#61]
I can not directly find anything about this with google on why the link is not shown. Are you registered with github? Maybe that is a requirement but I doubt it.

I can make a zip myself and give the link and I would try to keep it up to date. Let me know.

edit : I do think you need to be registered at github because cloning is a member feature I am sure. It is free btw.

dawlane(Posted February) [#62]
@Pakz: You have linked directly to the file view in the repository and not the download/clone which is only meant only for the entire repository. The file view has a button to called Raw see the file in un-formatted raw form.

@dubbsta: If you are seeing error native file system not implemented. Then the compiler target for that version of MonkeyX doesn't support a particular module or function set that you are trying to use. Such errors will show the module that is causing the problem and you can work out what targets are valid for that module.

This is one of the reasons why MonkeyX is not the best language for a beginner.

Pakz(Posted February) [#63]
I made a code file for dubbsta with a requestdir command used. That must not be supported on his target then.

This github stuff is complex :(

therevills(Posted February) [#64]
@Dawline, if you go to the home section you should see the clone & download button:

dawlane(Posted February) [#65]
@therevills: Pakz had directly linked to the file view and not to the repository home. The 'download/clone' that I linked is the the repository home page. Maybe I should have made that much more clearer in that post.

If anyone needs to get to the repository home page from the file view all they need to do is to click the blue links on the top left. The one near the branch drop down box is for navigating the current repository. The one at the top is for currently selected repository and to access the users other repositories.

dubbsta(Posted February) [#66]
so what can i do to fix it? i still dont really get it. or would it be easier for pakz to run the code and reupload the files?

dawlane(Posted February) [#67]
No because the problem lies with the target and what support for it is in the modules.
To fix it you would have to know the targets API and know how to write native code. Not something a novice or someone looking for write once compile any where tool chain would expect to have to deal with.
For example the requester module only supports Windows and OS X, not Linux. Implementing this on Linux requires a lot more knowledge due to the number of desktop environments, GUI framework quirks and framework incompatibilities; GLFW does not work well with GTK. If someone wanted requesters on Linux with MonkeyX; then they would find that the best way would be to write a GTK target, but even that would throw up a few problems

Pakz(Posted March) [#68]
I am not that experienced with github. I upload using the website there. One at a time. Up until recently I did not know monkey did not handle the filenames I used well. I tried using the github tool but could not understand how to use it/set it up. I also have already linked to the sourcode from elsewhere and that would break the links If I could figure out how to re-upload using the git tool. If I learn one day to use the github tools then I will see.

Here is the current contents with the modified filenames :

I finished with the book with 2d game collision code. I added a whole bunch of example code to the list here (middle section bottom) I was not able to recreate every thing from the book. I spend hours trying to fix 5 examples. They are not on the list here. They are on the github but the first line tells that it does not work correctly (mostly the oriented rectangle code is broken)

dawlane(Posted March) [#69]
I tried using the github tool but could not understand how to use it/set it up.
Are you using the web based tool or the GitHub Desktop Application? I find that this git tool is better. It's also cross platform and has a few tutorial on how to use it.

Youtube tutorials

Edit: There is also GitKraken

dubbsta(Posted March) [#70]
cool beans Pakz

edit: hate to burst your bubble, just a fyi alot of the file names have (-) wich is also giving monkey a problem. but when ever your'e up to it..

Pakz(Posted March) [#71]
I updated the zip above : The - chars are removed.

Pakz(Posted April) [#72]
I bought a new programming book. It is called "Mazes for programmers" I received it half a day ago and have started reading it.

The book is somewhat understandable for me, not to difficult. I have already added 3 maze generation examples on the blog and github. (Not linked in the list yet)

If I can understand all 12 maze generation methods from the book than they will start to appear on the blog. Maybe there is more in the book that can be turned into examples.

It wil take a while for me to finish the book since it is a nice 270+ pages thick.

slenkar(Posted April) [#73]
Thanks for these demos
I tried changing the origin of line in the line vs rectangle demo,
it doesnt seem to work anymore?
' From the book '2d game collision detection'
' rectangle vs Line collision

Import mojo

' This is the collision class.
Class collision
    ' Collision function
    ' The rectangle vs Line Collision
    Function line_rectangle_collide:Bool(l:line,r:rectangle)
        Local n:vector2d = rotate_vector_90(l.direction)
        Local dp1:Float,dp2:Float
        Local dp3:Float,dp4:Float
        Local c1:vector2d = r.origin
        Local c2:vector2d = add_vector(c1,r.size)
        Local c3:vector2d = New vector2d(c2.x,c1.y)
        Local c4:vector2d = New vector2d(c1.x,c2.y)
        c1 = subtract_vector(c1,l.base)
        c2 = subtract_vector(c2,l.base)
        c3 = subtract_vector(c3,l.base)
        c4 = subtract_vector(c4,l.base)                        
        dp1 = dot_product(n,c1)
        dp2 = dot_product(n,c2)
        dp3 = dot_product(n,c3)
        dp4 = dot_product(n,c4)
        Return     (dp1 * dp2 <= 0) Or
                (dp2 * dp3 <= 0) Or
                (dp3 * dp4 <= 0)
    End Function

    ' helper functions
    Function rotate_vector_90:vector2d(v:vector2d)
        Local r:vector2d = New vector2d()
        r.x = -v.y
        r.y = v.x
        Return r
    End Function

    Function add_vector:vector2d(a:vector2d,b:vector2d)
        Local r:vector2d = New vector2d(0,0)
        r.x = a.x + b.x
        r.y = a.y + b.y
        Return r
    End Function  

    Function subtract_vector:vector2d(a:vector2d,b:vector2d)
        Local r:vector2d = New vector2d()
        r.x = a.x - b.x
        r.y = a.y - b.y
        Return r
    End Function

    Function dot_product:Float(a:vector2d,b:vector2d)
        Return a.x * b.x + a.y * b.y 
    End Function    
End Class

Class vector2d
    ' x and y hold the position of the vector
    Field x:Int,y:Int
    Method New(x:Int,y:Int)
        Self.x = x
        Self.y = y
    End Method
End Class

Class line
    Field base:vector2d
    Field direction:vector2d
    Method New(base:vector2d,direction:vector2d)
        Self.base = base
        Self.direction = direction
    End Method
    Method draw()
        DrawLine base.x,base.y,direction.x,direction.y
    End Method
End Class

Class rectangle
    ' origin is a vector that holds the x and y coordinates
    ' of the rectangle
    Field origin:vector2d
    ' size is a vector that holds the x(width) and 
    ' y(height) of the rectangle
    Field size:vector2d
    Method New(origin:vector2d,size:vector2d)
        Self.origin = origin
        Self.size = size
    End Method
    Method draw()
        ' x1,y1,w,h are used to hold the rectangle
        ' location and size.
        Local x1:Int=origin.x
        Local y1:Int=origin.y
        Local w:Int=size.x
        Local h:Int=size.y
        DrawRect x1,y1,w,h
    End Method
End Class

' col is the caller of the class collision. 
' we use it to use the collision methods.
Global col:collision = New collision

Class MyGame Extends App
    Field angle:Float
    Method OnCreate()
    End Method
    Method OnUpdate()
        If angle > 360 Then angle = 0  
    End Method
    Method OnRender()
        Cls 0,0,0 
        SetColor 255,255,255
        ' this is a line setup
        Local base:vector2d = New vector2d(100,0)
        Local direction:vector2d = New vector2d(MouseX,MouseY)
        Local line1:line = New line(base,direction)
        ' This is the rectangle
        Local origin:vector2d = New vector2d(320,200)
        Local size:vector2d = New vector2d(100,100)
        Local rect1:rectangle = New rectangle(origin,size)

        ' Here we test for collision
        If col.line_rectangle_collide(line1,rect1)
            DrawText "Line vs Rectangle Collision",0,0
            DrawText "Line vs Rectangle NO Collision",0,0
        End If
        ' Here we draw the line and rectangle
        DrawText "Move the Mouse to test for Collision",DeviceWidth/2,0
        DrawText "Info : Lines are infinite in length.",DeviceWidth/2,20
    End Method
End Class

Function Main()
    New MyGame()
End Function

Pakz(Posted April) [#74]
What the code is supposed to be doing is to check if any of the 4 corners of the rectangle are on either side of the line. If they are then there is no collision.

I can not find why the problem is happening. It might take me a while to figure out the problem.

In the meanwhile if you wish you could check the code in the zip below. Maybe you can find a typo. It it the original code from the book.

Pakz(Posted May) [#75]
I added the maze algorithms to the Middle Section of the list. I made all but 1 of the Maze book. (mazes for programmers)

Pakz(Posted June) [#76]
I had gotten close to 40.000 all time page views. This in 2 years and some. When a monkeyx forum is created on the monkey2 site I will probably create a post there with the links to the blog applets/code and github.

Pakz(Posted June) [#77]
The Blitzbasic forum is already gone. This forum might follow soon.

I created a page on my homepage with the links in here. It will probably turn up in search engine results in the future.