Introducing the Colour Maximite 2
Author | Message | ||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 6382 |
To anyone thinking this. Please do read Geoff's excellent Introduction to programming the CMM2 Yes there are lots of capabilities but at heart it is a simple Basic computer. Even quite complex looking things are really quite easy. For example this is the complete code for the ghost demo ' lets play some music while the demo is running - how about "Hotel California" ' substitute something more to your taste here or comment out play mp3 "hotel" 'set to 640x400 mode with 2 video layers and 12-bit colour. Page 0 is the bottom layer and page 1 is the top mode 2,12 'clear the first three framebuffers (pages) for i=0 to 2:page write i:cls:next i 'load a sprite which is the image of the ghost from a png file. 'The fact it is a png is important as png files encode transparency as well as solid colours sprite loadpng 1,"ghost" 'set that we are going to write to the background layer page write 0 'load the background image to the background layer - page 0 load png "part02" 'The image I am using is only 320x200 so I'm going to resize it to fit the screen image resize 0,0,320,200,0,0,640,400 'initialise the display position of the ghost x=100 y=50 'initialise the transparency of the ghost ' transparencies go from 1 (nearly invisible) to 15 (solid colour) t=8 'set to write to page 2 which is not being displayed page write 2 ' output the ghost on page 2 sprite show 1,x,y,1 i=0 'start the main process loop do 'do some silly maths to create a random walk of the ghost in both position and ' transparency while keeping it within the display bounds and the transparency ' within useful limits i=i+1 if i mod 5 = 0 then c=rnd()-0.5 if i mod 3 = 0 then a=rnd()*8-4 if i mod 3 = 0 then b=rnd()*6-3 x=x+a if x<0 then x=0 if x>MM.HRES-sprite(w,1) then x=mm.hres-sprite(w,1) y=y+b if y<0 then y=0 if y>MM.VRES-sprite(h,1) then y=mm.vres-sprite(h,1) t=t+c if t<3 then t=3 if t>12 then t=12 'display the sprite in the new position and with the new transparency sprite transparency 1,t sprite show 1,x,y,1 'now copy page 2 to the foreground layer during frame blanking 'this ensures that there are no tearing effects in the image page copy 2 to 1,b 'slow things down a bit, the CMM2 is too fast pause 100 loop Image files Ghost.zip |
||||