Spring is Here

Post Reply
User avatar
rbytes
Posts: 1798
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone X
iPad 4
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Spring is Here

Post by rbytes » Sun Apr 01, 2018 3:51 pm

Based on my wishful thinking, and a routine by Operator called Sprite Scaling.

Code: Select all

/*Spring is Here by rbytes
April 1, 2018
Based on Sprite Scaling by Operator
Runs on all devices
*/

OPTION ANGLE DEGREES
SET TOOLBAR OFF
SHADOW ON
GRAPHICS
GRAPHICS CLEAR
GET SCREEN SIZE sw,sh
'sw=568 ' my iphone width
'sh=320 ' my iphone height
IF sw<>1024 THEN modi=.3 ELSE modi=.8
rw=sw/1024!rh=sh/768


' This sprite is an eraser
SPRITE 1 BEGIN 102*rw,102*rw
GRAPHICS CLEAR 0,0,0
SPRITE END
SPRITE 1 SHOW


' This sprite draws the leaves
FILL COLOR 0,.7,0
SPRITE 2 BEGIN 102*rw,102*rw
GRAPHICS CLEAR
FILL CIRCLE 51*rw,51*rw SIZE 50*rw
SPRITE END
SPRITE 2 SHOW

' this sprite stamps the red flower heads
FILL COLOR 1,0,0
SPRITE 3 BEGIN 102*rw,102*rw
GRAPHICS CLEAR
FILL CIRCLE 51*rw,51*rw SIZE 50*rw
FILL COLOR .4,0,0
FILL CIRCLE 51*rw,51*rw SIZE 10*rw
SPRITE END

GET SPRITE 1 SIZE spr_w,spr_h

' this sprite is the complete flower with leaves and stem
SPRITE 4 BEGIN 480*rw,480*rw
FOR spr_scl = 3.2 TO 0.5 STEP -0.5
  SPRITE 1 AT 224*rw-(spr_scl-1)*spr_w/2,0+(spr_scl-1)*spr_h/2 SCALE spr_scl
  SPRITE 2 AT 224*rw-(spr_scl-1)*spr_w/2,0+(spr_scl-1)*spr_h/2 SCALE spr_scl
  SPRITE 3 AT 224*rw-(spr_scl-1)*spr_w/2,0+(spr_scl-1)*spr_h/2 SCALE spr_scl
  GRAPHICS MODE CLEAR
  SPRITE 1 STAMP
  GRAPHICS MODE NORMAL
  SPRITE 2 STAMP
  PAUSE 0.2
NEXT spr_scl
PAUSE .5
SPRITE 1 HIDE
SPRITE 2 HIDE

' this line is the stem
DRAW SIZE 8*rw
DRAW COLOR 0,.7,0
DRAW LINE 0,326*rw TO 312*rw,14*rw

' now stamp a flower head
SPRITE 3 STAMP

SPRITE 4 END
SPRITE 4 SHOW
PAUSE 2

' this code draws the scene
' first, clear the screen to the sky color
GRAPHICS CLEAR 0,.7,1

PAUSE 1.5

' next, draw the land
FILL COLOR .4,.4,0
FILL RECT 0,sh*.5 TO sw,sh

PAUSE 1.5

' now draw the flowers at random horizontal locations.
' they get larger as the loop increases, and also are positioned
' lower on screen to give perspective
FOR t = 1 TO 60
  'notice the -45 angle. this is necessary to rotate the sprite for vertical flowers!
  SPRITE 4 AT RND(sw)-200*rw, t*6*modi-300*rw+sh*.6 SCALE (t*rh)/120+RND(.15*rh*1/modi) ANGLE -45
  SPRITE 4 STAMP
  PAUSE .1
NEXT t
FILL COLOR 1,1,0
SHADOW OFF

' last, draw a sun
FILL CIRCLE sw*.7,60*rh SIZE 35*rh
PAUSE 5
 
Attachments
F5F3CB12-389B-4669-890F-868EF0378C10.png
F5F3CB12-389B-4669-890F-868EF0378C10.png (689.82 KiB) Viewed 1262 times
####### Living the colorful life #######

Post Reply