witch&
= _LoadImage("witch.png"): witchx
= -300: witchy
= 100 + (Rnd * 300)
jackys = 7
Dim Shared jackysx
(jackys
), jackysy
(jackys
), jackysr
(jackys
)
'======
restart:
'======
witchflyx = 20
witchflyy = 300
grassx = 0
candycount = 0
PPRINT
300, 10, 16, _RGB(255, 255, 255), 255, Str$(candycount
)
'draw candies
'_PUTIMAGE (jackysx(j), jackysy(j)), candy&
RotoZoom3 jackysx
(j
), jackysy
(j
), candy&
, 1, 1, _D2R(jackysr
(j
)) ' check boundary of images with circles, confirm jackysx(j), jackysy(j) is a center NOT a CORNER
Circle (jackysx
(j
), jackysy
(j
)), 75 / 2, &HFFFFFFFF jackysr(j) = jackysr(j) + 3
If jackysr
(j
) > 360 Then jackysr
(j
) = 1
'if pressed space
witchflyy = witchflyy - 2
witchflyx = witchflyx + 1
witchflyy = witchflyy + 1
witchflyx = witchflyx - .5
'keep witch in bounds
If witchflyx
< 5 Then witchflyx
= 5 If witchflyy
< 40 Then witchflyy
= 40 If witchflyy
> 500 Then witchflyy
= 500
' collision%(wx1 + 15, wy1 + 15, 60, 60, jackysx(j) - 37, jackysy(j) - 37, 60, 60) ' dav's mod
Line (witchflyx
+ 15, witchflyy
+ 15)-Step(60, 60), &HFFFFFFFF, B
grassx = grassx - 1
If grassx
<= -640 Then grassx
= 0
'========================= collision dectection here ===========
'see if witch hit a candy
wx1 = witchflyx: wy1 = witchflyy
wx2 = wx1 + 75: wy2 = wy1 + 75
jx1 = jackysx(j): jy1 = jackysy(j)
jx2 = jx1 + 75: jy2 = jy1 + 75
'hit = 0
'If wx2 >= jx1 Then
' If wx1 <= jx2 Then
' If wy2 >= jy1 Then
' If wy1 <= jy2 Then hit = 1
' End If
' End If
'End If
'hit = collision%(wx1, wy1, 75, 75, jackysx(j) - 37, jackysy(j) - 37, 60, 60)
hit = collision%(wx1 + 15, wy1 + 15, 60, 60, jackysx(j) - 37, jackysy(j) - 37, 60, 60) ' dav's mod
PPRINT
300, 10, 16, _RGB(255, 255, 255), 255, Str$(candycount
)
'draw jacks
' _PUTIMAGE (jackysx(j), jackysy(j)), candy&
RotoZoom3 jackysx
(j2
), jackysy
(j2
), candy&
, 1, 1, _D2R(jackysr
(j2
))
'spin witch out here
r = 1
RotoZoom3 witchflyx
+ 75, dy
, witch&
, 1, 1, _D2R(r
) r
= r
+ 5:
If r
> 360 Then r
= 1
'move candies, compute
jackysx(j) = jackysx(j) - 2
candycount = candycount + 1
'If won...
Sub PPRINT
(x
, y
, size
, clr&
, trans&
, text$
) 'This sub outputs to the current _DEST set
'It makes trans& the transparent color
'x/y is where to print text
'size is the font size to use
'clr& is the color of your text
'trans& is the background transparent color
'text$ is the string to print
'=== get users current write screen
'=== if you are using an 8 or 32 bit screen
'=== step through your text
'=== make a temp screen to use
'=== set colors and print text
'== make background color the transprent one
'=== go back to original screen to output
'=== set it and forget it
x1 = x + (t * size): x2 = x1 + size
y1 = y: y2 = y + size
_PutImage (x1
- (size
/ 2), y1
)-(x2
, y2
+ (size
/ 3)), pprintimg&
' Description:
' Started from a mod of Galleon's in Wiki that both scales and rotates an image.
' This version scales the x-axis and y-axis independently allowing rotations of image just by changing X or Y Scales
' making this tightly coded routine a very powerful and versatile image tool.
' This assumes you have set your drawing location with _DEST or default to screen.
' X, Y - is where you want to put the middle of the image
' Image - is the handle assigned with _LOADIMAGE
' xScale, yScale - are shrinkage < 1 or magnification > 1 on the given axis, 1 just uses image size.
' These are multipliers so .5 will create image .5 size on given axis and 2 for twice image size.
' radianRotation is the Angle in Radian units to rotate the image
' note: Radian units for rotation because it matches angle units of other Basic Trig functions
' and saves a little time converting from degree.
' Use the _D2R() function if you prefer to work in degree units for angles.
Dim W&
, H&
, sinr!
, cosr!
, i&
, x2&
, y2&
' variables for image manipulation px(0) = -W& / 2: py(0) = -H& / 2 'left top corner
px(1) = -W& / 2: py(1) = H& / 2 ' left bottom corner
px(2) = W& / 2: py(2) = H& / 2 ' right bottom
px(3) = W& / 2: py(3) = -H& / 2 ' right top
sinr!
= Sin(-radianRotation
): cosr!
= Cos(-radianRotation
) ' rotation helpers For i&
= 0 To 3 ' calc new point locations with rotation and zoom x2& = xScale * (px(i&) * cosr! + sinr! * py(i&)) + X: y2& = yScale * (py(i&) * cosr! - px(i&) * sinr!) + Y
px(i&) = x2&: py(i&) = y2&
Function collision%
(b1x
, b1y
, b1w
, b1h
, b2x
, b2y
, b2w
, b2h
) ' x, y represent the box left most x and top most y
' w, h represent the box width and height which is the usual way sprites / tiles / images are described
' such that boxbottom = by + bh
' and boxright = bx + bw
'so the specific gosub above is generalized to a function procedure here!
If (b1y
+ b1h
< b2y
) Or (b1y
> b2y
+ b2h
) Or (b1x
> b2x
+ b2w
) Or (b1x
+ b1w
< b2x
) Then collision% = 0
collision% = -1 ' Collsion is true