Skip to content

Commit 0383cea

Browse files
author
Mark Sibly
committed
Added html5 mojo
1 parent 891df84 commit 0383cea

File tree

273 files changed

+32819
-7
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

273 files changed

+32819
-7
lines changed

.gitignore

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
bin
2-
modules/mojo
3-
modules/brlx
4-
src/rebuildall
5-
src/rebuilaall.exe
6-
src/george/src_docs/_mojo.*
7-
docs/html/_mojo.*
2+
83
Monkey
94
Monkey.app
105
Monkey.exe
11-
bananas
126

7+
src/rebuildall
8+
src/rebuilaall.exe
9+
10+
modules/brlx
11+
12+
modules/mojo/native/*
13+
!modules/mojo/native/mojo.html5.js
14+
!modules/mojo/native/asyncimageloader.js

README.TXT

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
For more Monkey fun, please visit: http://www.monkeycoder.co.nz
2+
3+
Monkey is released under the zlib/libpng license.
4+
15
The zlib/libpng License
26

37
Copyright (c) 2013 Blitz Research Ltd
27.8 KB
Loading
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
'******************************************************************
2+
'* Tile Image Example
3+
'* Author: Richard R Betson
4+
'* Date: 01/23/11
5+
'* Language: monkey
6+
'* Tagets: HTML5, FLASH, GLFW
7+
'* License - Public Domain
8+
'******************************************************************
9+
10+
Import mojo
11+
12+
Function Main()
13+
New TileImage
14+
End Function
15+
16+
17+
Class TileImage Extends App
18+
Field img:Image
19+
Field ix#,iy#
20+
Field scale_width#=1.0,scale_hieght#=1.0
21+
22+
Method OnCreate()
23+
SetUpdateRate(60)
24+
img=LoadImage( "bg.png" )
25+
SetFont Null
26+
End Method
27+
28+
Method OnUpdate()
29+
30+
If KeyDown (KEY_LEFT)
31+
scale_width = scale_width - 0.1
32+
If scale_width < 1.0 Then scale_width = 1.0
33+
Endif
34+
If KeyDown (KEY_RIGHT)
35+
scale_width = scale_width + 0.1
36+
Endif
37+
If KeyDown (KEY_DOWN)
38+
scale_hieght = scale_hieght - 0.1
39+
If scale_hieght < 1.0 Then scale_hieght = 1.0
40+
Endif
41+
If KeyDown (KEY_UP)
42+
scale_hieght = scale_hieght + 0.1
43+
Endif
44+
45+
End Method
46+
47+
Method OnRender()
48+
Local ih=128,iw=128
49+
Local scale_x#=.99 'Some browsers like FireFox need a .01 offset to display right
50+
Local scale_y#=.99
51+
52+
'Cls 0,0,0
53+
PushMatrix()
54+
55+
Translate DeviceWidth * 0.5, DeviceHeight * 0.5 'Thanks BlitzSupport:)
56+
Scale scale_width,scale_hieght
57+
Translate -DeviceWidth * 0.5, -DeviceHeight * 0.5' ""
58+
59+
ix=ix+1.5
60+
iy=iy+1
61+
Tile_Image(img,ix,iy,ih,iw,scale_x,scale_y)
62+
PopMatrix()
63+
64+
PushMatrix()
65+
Translate(0,0)
66+
Scale (1,1)
67+
SetBlend 0
68+
DrawText("Use Arrow Keys to adjust scale.",10,10)
69+
70+
PopMatrix()
71+
72+
End Method
73+
74+
75+
76+
Function Tile_Image(img:Image,x#,y#,ih,iw,scalex#,scaley#)
77+
'Based in part on - http://www.blitzbasic.com/codearcs/codearcs.php?code=1842
78+
Local w#=iw * scalex
79+
Local h#=ih * scaley
80+
81+
Local scissor:Float[]
82+
scissor=GetScissor()
83+
Local viewport_x=scissor[0]
84+
Local viewport_y=scissor[1]
85+
Local viewport_w=scissor[2]
86+
Local viewport_h=scissor[3]
87+
88+
Local ox#=viewport_x-w+1
89+
Local oy#=viewport_y-h+1
90+
91+
Local px#=x
92+
Local py#=y
93+
94+
Local fx#=px-Floor(px)
95+
Local fy#=py-Floor(py)
96+
Local tx#=Floor(px)-ox
97+
Local ty#=Floor(py)-oy
98+
99+
If tx>=0 tx=tx Mod w + ox Else tx = w - -tx Mod w + ox
100+
If ty>=0 ty=ty Mod h + oy Else ty = h - -ty Mod h + oy
101+
102+
Local vr#= viewport_x + viewport_w, vb# = viewport_y + viewport_h
103+
104+
Local iy#=ty
105+
While iy<(vb + h)
106+
Local ix#=tx
107+
While ix<(vr + w)
108+
DrawImage(img,ix+fx,iy+fy)
109+
ix=ix+w
110+
Wend
111+
iy=iy+h
112+
Wend
113+
End Function
114+
115+
116+
End Class
117+
118+

0 commit comments

Comments
 (0)