How do I get the image on the screen?

Community Forums/Monkey Talk/How do I get the image on the screen?

Hotshot2005(Posted 2011) [#1]
I been using Blitz Monkey demo....

I got my own Spaceship pic on my desktop and also Blitz Monkey program that I have made

OH RIGHT I see......I cant seem get Player Image on the Screen :(

Import mojo

Class DrawTest Extends App
      Field Player:Image

      Method OnCreate()
             Player=LoadImage("player.png")
             SetUpdateRate 60
      End

      Method OnUpdate()
            
      End

      Method OnRender()
             Cls 255,255,255
             DrawImage Player,320,10
      End
End Class


Function Main()
         New DrawTest
End 


When I run the program....why it is all white when there is no spaceship sprites on the screen?


therevills(Posted 2011) [#2]
You need to create a folder in your project folder called "yourapp.data", then place your images in there... took me awhile to find that out too!

test.monkey:


Enemy1.png is stored in test/test.data

Last edited 2011


Hotshot2005(Posted 2011) [#3]
Ok I did copy the code and paste to my blitz monekey demo and save it as MYApp then I put image in data of the MyApp folder then Data folder and put image in there.

I run the program and it doesnt show the image and I went to check the data folder and the image is GONE....it is a bug?

P.S. I am using Chome for HMTL5 thank you

Last edited 2011


Hotshot2005(Posted 2011) [#4]
why is this?

TRANS monkey compiler V1.01
Parsing...
Semanting...
Translating...
Building...
FOPEN 'wb' for CopyFile(C:/Users/hotshot/Desktop/MonkeyDemo29/modules/mojo/data/mojo_font.png,C:/Users/hotshot/myApp.build/html5/data/mojo_font.png) failed
FindFirstFileW for LoadDir(C:/Users/hotshot/Desktop/myApp.build/html5/data/) failed

Last edited 2011

Last edited 2011


SLotman(Posted 2011) [#5]
Arg! Don't tell me this OnCreate/OnLoad/OnUpdate/OnRender - which awfully remembers me of J2ME is the syntax used by Monkey... =(

I plain hate to code things like that :P~


Hotshot2005(Posted 2011) [#6]
it would be nice for once knowing how put image on the screen....even thought my sprites image in the data folder but it not showing on the screen :(

MyApp Folder>>Data Folder>>Enemy1.png

I cant understand why the sprites image isnt on the screen

Does anyone know?

Last edited 2011


therevills(Posted 2011) [#7]
What is your folder structure?

Here is mine:
test/
  test.monkey
  test.data/
    enemy1.png

You see test.monkey is stored in test and the enemy1.png is stored in test.data in test.

Last edited 2011


Hotshot2005(Posted 2011) [#8]
I gonna try Internet Explore 9 and see if can get the image on the screen...


Hotshot2005(Posted 2011) [#9]
My folder is

MyApp/

TestGame.Monkey
TestGame.data/
Enemy1.png

I cant understand why image isnt on the screen and when i finished running the program then went check the data folder and the image is GONE!

I could show you some picture if you want to see it!

Last edited 2011


therevills(Posted 2011) [#10]
That looks right.... where is it stored? Mine is on the desktop and Im using Chrome...

Have you tried the Sample Program Basic game by James Boyd?


Hotshot2005(Posted 2011) [#11]
Have you tried the Sample Program Basic game by James Boyd?

Yep that work fine

I have my Appfolder at the desktop and I using Chrome.....why my image isnt working when James Boyd Basic game work!

I am really Baffle by it :(

I going put image picture to show on what I did to save people asking me questions :)


marksibly(Posted 2011) [#12]
Hi,

> FOPEN 'wb' for CopyFile(C:/Users/hotshot/Desktop/MonkeyDemo29/modules/mojo/data/mojo_font.png,C:/Users/hotshot/myApp.build/html5/data/mojo_font.png) failed
FindFirstFileW for LoadDir(C:/Users/hotshot/Desktop/myApp.build/html5/data/) failed

This looks dodgy - have you installed it to 'Program Files'? Try installing to C:\MonkeyDemo instead.


therevills(Posted 2011) [#13]
Could you upload a zip of your project somewhere?


Hotshot2005(Posted 2011) [#14]
I have try putting Blitz Monkey in C:\ Drive and I save my work in desktop and I still get the same error :(

Part 1


Part 2


Part 3


Part 4


When I run the Program and I get this...image should be showing on the screen



When the program finished and I check(look at Part 6) the data but the data folder is gone and sometime the image is gone.....I dont know why....

Part 6


Last edited 2011

Last edited 2011


therevills(Posted 2011) [#15]
That looks like your files on directly on the desktop... is that right?

Could you upload a zip of your project somewhere?


Hotshot2005(Posted 2011) [#16]
yes...my work program app is on the desktop


BlitzSupport(Posted 2011) [#17]
Hi Hotshot2005, can you upload your whole project somewhere as a zip file as therevills suggests? We need to see if it works for us.


Hotshot2005(Posted 2011) [#18]
OK BlitzSupport :)


Hotshot2005(Posted 2011) [#19]
there you go :)

http://www.mediafire.com/?1cewe3k5bsnuvtf


therevills(Posted 2011) [#20]
Can you try and put all your project files into one folder on the desktop:

Desktop/
  MonkeyGame/
     test1.monkey
     test1.data/
       enemy1.png



therevills(Posted 2011) [#21]
We need all the files Hotshot, including the source code etc... not just the build files...

Last edited 2011


Hotshot2005(Posted 2011) [#22]
OK therevills, I will try that :)


therevills(Posted 2011) [#23]
Maybe just maybe, try renaming your image file from enemy1.PNG to enemy1.png ;)


Hotshot2005(Posted 2011) [#24]
how Do I get the source code(even when i save the program!) as when i run the program then should compiler the code(from your code that you made the image print on the screen) and the source code should be in the folder....

here on what you have said that i should put in all in project files into one folder on the desktop :)


there you go

http://www.mediafire.com/?eaetsly7xoz78nb


Hotshot2005(Posted 2011) [#25]

Maybe just maybe, try renaming your image file from enemy1.PNG to enemy1.png ;)



I have try that and it failed :(

sigh


Hotshot2005(Posted 2011) [#26]
I have try the Example - Your First Application


Strict

Import mojo.app

Import mojo.graphics

 

Function Main:Void()

       New BlueScreen

End

 

Class BlueScreen Extends App

       Method OnRender:Int()

              Cls 0,0,200

              DrawText "You got a bluescreen",200,200

              Return 0

       End Method
End


It show the blue screen which work fine but when come to image code(the one you have made) on the screen......I dont know why doesnt show image on the screen even the image in the data folder!

Last edited 2011


therevills(Posted 2011) [#27]
Okay lets start from the beginning.

1. Create a folder on your desktop called MonkeyTest
2. In MonkeyTest create a folder called monkeytest.data
3. Place you enemy1.png into monkeytest.data
4. Create a file in MonkeyTest called monkeytest.monkey
5. Open Monk IDE
6. Open monkeytest.monkey
7. Copy the following and paste into monkeytest.monkey



8. Save
9. Press F5 and select HTML5 and click Build


Hotshot2005(Posted 2011) [#28]
I have follow the simple instructions on what You have said but failed :(

http://www.mediafire.com/?qxsx888jkl5nl4j

tell me where I have gone wrong :(


therevills(Posted 2011) [#29]
Your image file is still called "enemy1.PNG", rename it in windows to be "enemy1.png". Once I did this, your code works fine.

I notice that you dont display known extensions in windows - put them on!!! :P

Last edited 2011

Last edited 2011


BlitzSupport(Posted 2011) [#30]
It's because Monkey is case-sensitive -- your image is in fact called enemy1.PNG, but you don't have file extensions turned on in your screenshots.

It should work if you change the LoadImage call to enemy1.PNG, *or* turn on file extensions and make the name lower-case.


BlitzSupport(Posted 2011) [#31]
Doh!


Hotshot2005(Posted 2011) [#32]
YES it does WORK......FINALLY!


I notice that you dont display known extensions in windows - put them on!!! :P



What is that? :S


BlitzSupport(Posted 2011) [#33]
BTW To show file extensions in Windows 7...

Click the Organize dropdown (see your screenshots), choose "Folder and search options" and click the View tab.

In the checkbox list, untick "Hide extensions for known file types".


Hotshot2005(Posted 2011) [#34]
thank you so much :)

I couldnt believe it such long thread about Case Senstive of not having image on the screen! LOL

Last edited 2011


therevills(Posted 2011) [#35]
Thank gawd!! LOL!

Ive started a Tips and Tricks thread over on Indiecodez for (M?)monkey:

http://www.indiecodez.com/forum/index.php/topic,112.msg4674.html#msg4674


Hotshot2005(Posted 2011) [#36]
Good Tips :) therevills

I just made Line Demo as my first program and I am going continue learning it and progress futher :)


Hotshot2005(Posted 2011) [#37]
Here the Line Demo Picture



There one things that stuck on me is when I put

SetColor(255,0,0)
DrawText "MY LINE DEMO",10,10

Should be Red Font instead of Black?

Another things I like to ask is.....every time I run the program....it run on Internet explore instead of Google Chrome(I did prefer to run it on google chrome) and how would I do that?


BlitzSupport(Posted 2011) [#38]
The mojo DrawText command is really just a cross-platform hack for test/debug purposes. You should use something like beaker's included angelfont system for 'proper' text.

Hotshot2005, you need to edit monkey\bin\config.winnt.txt and change the path that HTML_PLAYER is set to, after uncommenting the line it's on.

Your Internet Explorer path should probably be "${PROGRAMFILES}\Internet Explorer\iexplore.exe" but make sure you are using Internet Explorer 9 or HTML5 code won't work at all.

Back up config.winnt.txt before editing it!

Last edited 2011


Hotshot2005(Posted 2011) [#39]
it is possible to do this?

'--------------------
'Tool used to 'run' .html files.
'
'This is optional, OS default tool for .html files will be used if this not set.
'
HTML_PLAYER="${PROGRAMFILES}\Mozilla Firefox\Chrome.exe"
'--------------------


therevills(Posted 2011) [#40]
I have altered config.winnt.txt to be like this:

'--------------------
'Tool used to 'run' .html files.
'
'This is optional, OS default tool for .html files will be used if this not set.
'
HTML_PLAYER="D:\Documents and Settings\revills\Local Settings\Application Data\Google\Chrome\Application\chrome.exe"
'--------------------


Hotshot2005(Posted 2011) [#41]
thank you therevills as I was coding C64 Loading screen but it is slow even thought SetUpdateRate 60 is 60FPS ...I guess it is do with my For loop that could slow down I suppose....


Gabriel(Posted 2011) [#42]
I was coding C64 Loading screen but it is slow even thought SetUpdateRate 60 is 60FPS

You must be loading from cassette instead of the disk drive, eh? :P

Last edited 2011


Hotshot2005(Posted 2011) [#43]
HA HA HA :-P

Last edited 2011


Hotshot2005(Posted 2011) [#44]
that the code on what I did for C64 Loading

      For X=1 To 320
	  For Y=1 To 320
	      SetColor(Rnd(255),Rnd(255),Rnd(255))
	      DrawLine Rnd(X),Y,X,Y)
	  Next 
      Next



marksibly(Posted 2011) [#45]
Hi,

> thank you therevills as I was coding C64 Loading screen but it is slow even thought SetUpdateRate 60 is 60FPS ...I guess it is do with my For loop that could slow down I suppose....

HTML5 is an 'emerging' standard...performance wise, it can be pretty crap depending on what you're doing.

For best graphical results, I recommend installing the IE9 beta or whatever it's called now - this is VERY fast, although it doesn't do audio yet.

Or you can buy Monkey and use the GLFW target which uses OpenGL/C++!


taumel(Posted 2011) [#46]
I couldn't resist, a quick first try...

I had no problems with the images on OSX.
Compiling for GLFW takes quite some time.
It feels strange&cool beeing able to compile a blitz thing for the browser.
<All Beaker examples are missing the main.> all fine!
Can you decompress on load sounds for a better loop?

Last edited 2011

Last edited 2011

Last edited 2011


Beaker(Posted 2011) [#47]
taumel - what do you mean by "All Beaker examples are missing the main" ? There is only one example: angelfont_example.monkey !


taumel(Posted 2011) [#48]
I'm sorry this was my fault, all is fine. It was in middle of the night and the only reason i still was awake was due to monkey.


Hotshot2005(Posted 2011) [#49]
The monkey was aside of you and say "Program me please!" LOL


Hotshot2005(Posted 2011) [#50]
Does Blitz Monkey have Own Collisions or do you have make own Collisions? :(


Richard Betson(Posted 2011) [#51]
Roll your own for now.


Hotshot2005(Posted 2011) [#52]
To make my own Collisions? That isnt good! How the Newbie programmer going cope with Manual Collisions! :(


therevills(Posted 2011) [#53]
A really simple collision check:

Function rectsOverlap:Int(x0:Float, y0:Float, w0:Float, h0:Float, x2:Float, y2:Float, w2:Float, h2:Float)
	If x0 > (x2 + w2) Or (x0 + w0) < x2 Then Return False
	If y0 > (y2 + h2) Or (y0 + h0) < y2 Then Return False
	Return True
End Function