Posts: 323
Threads: 46
Joined: Apr 2022
Reputation:
11
08-17-2022, 05:24 PM
(This post was last modified: 08-17-2022, 05:25 PM by SierraKen.)
(08-17-2022, 05:08 PM)bplus Wrote: Ah yes, when my = heroY then the difference is 0 and will get division by 0 error, unless _ATAN2() can "tolerate" that condition which is possible if _ATAN2() were good because that is likely problem. So test my code and see if throws error when mouse is level with HeroY.
Update: Yeah, seems OK when my = HeroY so _ATAN2() can handle 0 in the 2nd argument. It has no problem drawing horizontal swords.
Interesting B+. I did wonder about something similar the other day. Also, when I did division by 0 on my calculator app, the outcome said: INF. So it is programmed to handle it.
Posts: 2,700
Threads: 124
Joined: Apr 2022
Reputation:
134
INF is not a number you can calculate with to get real useable numbers.
b = b + ...
Posts: 263
Threads: 14
Joined: Apr 2022
Reputation:
23
...and now for a more googly-eyed monster...
By doubling up the algorithm for each eye, we get independent action of each eyeball.
Code: (Select All) 'Following Eyes - Code by OldMoses mod by SierraKen
TYPE V2
x AS INTEGER
y AS INTEGER
END TYPE
DIM AS V2 m, h, h2, d, d2, sp, sp2
SCREEN _NEWIMAGE(800, 600, 32)
h.x = 350: h.y = 300
h2.x = 450: h2.y = 300
swordlength% = 5
DO
CLS
WHILE _MOUSEINPUT: WEND
R2_Mouse m
d = m: R2_Add d, h, -1 '
d2 = m: R2_Add d2, h2, -1 '
sp = d: R2_Norm sp, swordlength% '
sp2 = d2: R2_Norm sp2, swordlength% '
FOR sz = .25 TO 5 STEP .25
CIRCLE (h.x + sp.x, h.y + sp.y), sz, _RGB32(255, 255, 255)
CIRCLE (h2.x + sp2.x, h2.y + sp2.y), sz, _RGB32(255, 255, 255)
NEXT sz
CIRCLE (h.x, h.y), 15, _RGB32(255, 255, 255)
CIRCLE (h2.x, h2.y), 15, _RGB32(255, 255, 255)
CIRCLE (400, 325), 100, _RGB32(255, 255, 255)
CIRCLE (400, 365), 65, _RGB32(255, 255, 255), , , .3
_LIMIT 100
_DISPLAY
LOOP UNTIL _KEYDOWN(27)
END
'SUBROUTINES
SUB R2_Mouse (re AS V2) 'get mouse position vector and store in return
re.x = _MOUSEX
re.y = _MOUSEY
END SUB
SUB R2_Add (re AS V2, v AS V2, add AS INTEGER) 'adds or subtracts scalar multiples of v from return
re.x = re.x + (v.x * add)
re.y = re.y + (v.y * add)
END SUB 'R2_Add
SUB R2_Norm (re AS V2, scalar AS INTEGER) 'shrink return to unit vector and regrow by scalar amount
x! = re.x: y! = re.y
m! = _HYPOT(x!, y!)
IF m! = 0 THEN
re.x = 0: re.y = 0
ELSE
re.x = (x! / m!) * scalar
re.y = (y! / m!) * scalar
END IF
END SUB 'R2_Norm
DO: LOOP: DO: LOOP
sha_na_na_na_na_na_na_na_na_na:
Posts: 323
Threads: 46
Joined: Apr 2022
Reputation:
11
Well guys, I've been programming on this game all day long and have gotten nowhere because now it keeps freezing up every other time I test it. I removed the sound, one of the 2 dragons I had per level, and added tons of DIM statements for most of the variables. I also added a couple _LIMIT's in some key areas. But I'm guessing my computer just doesn't like how much processing it uses, which is around 18% or so. Which is a LOT compared to web browsers and other daily apps. So I need to put this game on hold for a little while and clear my mind and see if I can get things better. I do have to say that the code is pretty jumbled because I kept adding more things. If anyone wishes to see it, I'll post the code here. I cannot guarantee it will work, but feel free to look at it. Thankfully when it does freeze I am still able to click the X to close it. There's a chance it's just my computer too, I'm not sure. If you have any questions feel free to ask. One interesting thing is that it started freezing up even more times when I added the PLAY command in the beginning and during the fighting. But removing it does nothing. I even made another separate app today to make the opening theme song, which is "Eye of the Tiger" which I will post in the Programs section. Anyway, here's what I have. Feel free to do what you wish to it. I might even give up on this, I've just spent way too much time on something that might not even work. Comments are welcome of course, thanks. There's no extra files to this game. It usually either freezes at the starting screen or after I pass one of the dragons (levels). Often the 2nd or 3rd dragon. You might notice that I added the moving eyes to the dragon too. I don't want to give up on this completely, so hopefully we can figure it out.
Code: (Select All) 'Scrolling Map Example by SierraKen - August 17, 2022
'Thank you to Felippe, James D. Jarvis, mdijkens, Petr, and B+ for the help and inspiration!
Type object
x As Single
y As Single
End Type
Const ESC = 27
Dim Shared player As object
Dim Shared camera As object
Dim Shared map As Long
Dim mousex As Single, mousey As Single
Dim playerSpeed As Single
Dim housex(30)
Dim housey(30)
Dim housex2(30)
Dim housey2(30)
Dim hospitalx(30)
Dim hospitaly(30)
Dim hospitalx2(30)
Dim hospitaly2(30)
Dim armorx(30)
Dim armory(30)
Dim armorx2(30)
Dim armory2(30)
Dim lx(30)
Dim ly(30)
Dim cavex As Single, cavey As Single
Dim pillarx(30), pillary(30), pillarh(30), pillarwid(30)
Dim pyramidx(6), pyramidy(6), pyramidh(6)
Dim drag As Single
Dim drax As Single, dray As Single
Dim health As Single, town As Single, besthealth As Single, alreadydone As Single
Dim swordx As Single, swordy As Single, sx As Single, sy As Single
Dim gold As Single, armor As Single
Dim tx As Double, ty As Double
begin:
_Limit 60
_Title "Explorer - by Ken G"
town = 1
health = 500
besthealth = 500
armor = 10
alreadydone = 0
Randomize Timer
Screen _NewImage(800, 600, 32)
Cls
Print: Print: Print
Print " Explorer"
Print
Print " by Ken G."
Print: Print
Print
Print " Use the mouse to move and to turn your sword."
Print " Use the left mouse button to clear messages."
Print " Press Esc to quit."
Print " The object of the game is to get gold while"
Print " destroying the monsters."
Print " Passing 5 caves (levels) wins the game."
Print: Print
Print " Left Click the Screen With Your Mouse To Start."
Do
_Limit 60
While _MouseInput: Wend
mouseLeftButton = _MouseButton(1)
If mouseLeftButton Then
Clear_MB 1
GoTo start:
End If
Loop
start:
_Limit 60
player.x = _Width / 2
player.y = _Height / 2
If map <> 0 Then _FreeImage (map)
map = _NewImage(_Width * 5, _Height * 5, 32)
_Dest map
If town = 1 Then
Cls
'Grass
Line (0, 0)-(4000, 3000), _RGB32(0, 127, 0), BF
'Texture
For texture = 1 To 200000
tx = Rnd * 4000
ty = Rnd * 3000
Circle (tx, ty), 1, _RGB32(155, 166, 127)
Next texture
'Houses
For h = 1 To 20
again:
housex(h) = Rnd * 3500
housey(h) = Rnd * 2500
For check = 0 To h - 1
If housex(check) > housex(h) - 250 And housex(check) < housex(h) + 250 And housey(check) > housey(h) - 250 And housey(check) < housey(h) + 250 Then GoTo again:
Next check
housex2(h) = (Rnd * 100) + 50
housey2(h) = (Rnd * 100) + 50
'House
Line (housex(h), housey(h))-(housex(h) + housex2(h), housey(h) + housey2(h)), _RGB32(Rnd * 255, Rnd * 255, Rnd * 255), BF
'Roof
For sz = .25 To (housex2(h) / 2) Step .1
Circle (housex(h) + (housex2(h) / 2), housey(h)), sz, _RGB32(150, 75, 50), 2 * _Pi, _Pi, 1
Next sz
Line (housex(h) + (housex2(h) / 2) - 10, housey(h) + (housey2(h) - 20))-(housex(h) + (housex2(h) / 2) + 10, housey(h) + housey2(h)), _RGB32(128, 116, 128), BF
'Windows
For w = 0 To housey2(h) - 45 Step 15
Line (housex(h) + (housex2(h) / 2) - housex2(h) / 4, housey(h) + (housey2(h) - 35 - w))-(housex(h) + (housex2(h) / 2) - ((housex2(h) / 4) + 10), housey(h) + housey2(h) - 25 - w), _RGB32(128, 116, 128), BF
Line (housex(h) + (housex2(h) / 2) + housex2(h) / 4, housey(h) + (housey2(h) - 35 - w))-(housex(h) + (housex2(h) / 2) + ((housex2(h) / 4) + 10), housey(h) + housey2(h) - 25 - w), _RGB32(128, 116, 128), BF
Next w
Next h
'Hospitals
For ho = 1 To 5
ag:
hospitalx(ho) = Rnd * 3500
hospitaly(ho) = Rnd * 2500
For check = 0 To ho - 1
If housex(check) > hospitalx(ho) - 250 And housex(check) < hospitalx(ho) + 250 And housey(check) > hospitaly(ho) - 250 And housey(check) < hospitaly(ho) + 250 Then GoTo ag:
Next check
hospitalx2(ho) = (Rnd * 100) + 50
hospitaly2(ho) = (Rnd * 100) + 50
'House
Line (hospitalx(ho), hospitaly(ho))-(hospitalx(ho) + hospitalx2(ho), hospitaly(ho) + hospitaly2(ho)), _RGB32(255, 0, 0), BF
'Cross
Line (hospitalx(ho) + (hospitalx2(ho) / 2), hospitaly(ho) + 5)-(hospitalx(ho) + (hospitalx2(ho) / 2), hospitaly(ho) + 20), _RGB32(255, 255, 255)
Line (hospitalx(ho) + (hospitalx2(ho) * .4), hospitaly(ho) + 10)-(hospitalx(ho) + (hospitalx2(ho) * .6), hospitaly(ho) + 10), _RGB32(255, 255, 255)
'Roof
For sz = .25 To (hospitalx2(ho) / 2) Step .1
Circle (hospitalx(ho) + (hospitalx2(ho) / 2), hospitaly(ho)), sz, _RGB32(150, 75, 50), 2 * _Pi, _Pi, 1
Next sz
Line (hospitalx(ho) + (hospitalx2(ho) / 2) - 10, hospitaly(ho) + (hospitaly2(ho) - 20))-(hospitalx(ho) + (hospitalx2(ho) / 2) + 10, hospitaly(ho) + hospitaly2(ho)), _RGB32(128, 116, 128), BF
'Windows
For w = 0 To hospitaly2(ho) - 45 Step 15
Line (hospitalx(ho) + (hospitalx2(ho) / 2) - hospitalx2(ho) / 4, hospitaly(ho) + (hospitaly2(ho) - 35 - w))-(hospitalx(ho) + (hospitalx2(ho) / 2) - ((hospitalx2(ho) / 4) + 10), hospitaly(ho) + hospitaly2(ho) - 25 - w), _RGB32(128, 116, 128), BF
Line (hospitalx(ho) + (hospitalx2(ho) / 2) + hospitalx2(ho) / 4, hospitaly(ho) + (hospitaly2(ho) - 35 - w))-(hospitalx(ho) + (hospitalx2(ho) / 2) + ((hospitalx2(ho) / 4) + 10), hospitaly(ho) + hospitaly2(ho) - 25 - w), _RGB32(128, 116, 128), BF
Next w
Next ho
'Armories
For h = 1 To 5
agn:
armorx(h) = Rnd * 3500
armory(h) = Rnd * 2500
For check = 0 To h - 1
If housex(check) > armorx(h) - 150 And housex(check) < armorx(h) + 150 And housey(check) > armory(h) - 225 And housey(check) < armory(h) + 225 Then GoTo agn:
If hospitalx(check) > armorx(h) - 150 And hospitalx(check) < armorx(h) + 150 And hospitaly(check) > armory(h) - 225 And hospitaly(check) < armory(h) + 225 Then GoTo agn:
Next check
armorx2(h) = 125
armory2(h) = 125
'House
Line (armorx(h), armory(h))-(armorx(h) + armorx2(h), armory(h) + armory2(h)), _RGB32(0, 255, 0), BF
Color _RGB32(255, 0, 0), _RGB32(0, 255, 0)
_PrintString (armorx(h) + 40, armory(h) + 7), "Armory"
'Roof
For sz = .25 To (armorx2(h) / 2) Step .1
Circle (armorx(h) + (armorx2(h) / 2), armory(h)), sz, _RGB32(150, 75, 50), 2 * _Pi, _Pi, 1
Next sz
Line (armorx(h) + (armorx2(h) / 2) - 10, armory(h) + (armory2(h) - 20))-(armorx(h) + (armorx2(h) / 2) + 10, armory(h) + armory2(h)), _RGB32(128, 116, 128), BF
'Windows
For w = 0 To armory2(h) - 45 Step 15
Line (armorx(h) + (armorx2(h) / 2) - armorx2(h) / 4, armory(h) + (armory2(h) - 35 - w))-(armorx(h) + (armorx2(h) / 2) - ((armorx2(h) / 4) + 10), armory(h) + armory2(h) - 25 - w), _RGB32(128, 116, 128), BF
Line (armorx(h) + (armorx2(h) / 2) + armorx2(h) / 4, armory(h) + (armory2(h) - 35 - w))-(armorx(h) + (armorx2(h) / 2) + ((armorx2(h) / 4) + 10), armory(h) + armory2(h) - 25 - w), _RGB32(128, 116, 128), BF
Next w
Next h
Color _RGB32(255, 255, 255), _RGB32(0, 0, 0)
'Lakes
For rr = 1 To 30
again2:
lx(rr) = Rnd * 4000
ly(rr) = Rnd * 3000
For check = 0 To rr - 1
If lx(check) > lx(rr) - 250 And lx(check) < lx(rr) + 250 And ly(check) > ly(rr) - 250 And ly(check) < ly(rr) + 250 Then GoTo again2:
Next check
For check = 0 To 30
If housex(check) > lx(rr) - 250 And housex(check) < lx(rr) + 250 And housey(check) > ly(rr) - 250 And housey(check) < ly(rr) + 250 Then GoTo again2:
If hospitalx(check) > lx(rr) - 250 And hospitalx(check) < lx(rr) + 250 And hospitaly(check) > ly(rr) - 250 And hospitaly(check) < ly(rr) + 250 Then GoTo again2:
If armorx(check) > lx(rr) - 250 And armorx(check) < lx(rr) + 250 And armory(check) > ly(rr) - 250 And armory(check) < ly(rr) + 250 Then GoTo again2:
Next check
size = Int(Rnd * 150) + 20
shape = Rnd + .2
cl = 50
For sz = size To .25 Step -.25
cl = cl + .25
Circle (lx(rr), ly(rr)), sz, _RGB32(0, 0, cl + 50), , , shape
Next sz
cl = 0
Next rr
'pillars
pc = Int(11 + Rnd * 20)
For p = 1 To pc
checkpillars:
pillarx(p) = 100 + Rnd * 3300
pillary(p) = 100 + Rnd * 2300
For check = 0 To 20
If housex(check) > pillarx(p) - 250 And housex(check) < pillarx(p) + 250 And housey(check) > pillary(p) - 250 And housey(check) < pillary(p) + 250 Then GoTo checkpillars:
If hospitalx(check) > pillarx(p) - 250 And hospitalx(check) < pillarx(p) + 250 And hospitaly(check) > pillary(p) - 250 And hospitaly(check) < pillary(p) + 250 Then GoTo checkpillars:
If armorx(check) > pillarx(p) - 250 And armorx(check) < pillarx(p) + 250 And armory(check) > pillary(p) - 250 And armory(check) < pillary(p) + 250 Then GoTo checkpillars:
Next check
For check = 0 To 30
If lx(check) > pillarx(p) - 250 And lx(check) < pillarx(p) + 250 And ly(check) > pillary(p) - 250 And ly(check) < pillary(p) + 250 Then GoTo checkpillars:
Next check
pillarwid(p) = 4 + Int(Rnd * 20)
pillarh(p) = pillarwid(p) + Int(Rnd * (6 * pillarwid(p)))
pr = 30 + Rnd * 200: pg = 30 + Rnd * 200: pb = 30 + Rnd * 200
For px = pillarx(p) - pillarwid(p) To pillarx(p) + pillarwid(p)
Line (px, pillary(p))-(px, pillary(p) + pillarh(p)), _RGB32(pr, pg, pb)
Next
If Rnd * 6 > 2.5 Then
For px = pillarx(p) - (pillarwid(p) + pillarwid(p) / 5) To pillarx(p) + pillarwid(p) + pillarwid(p) / 5
Line (px, pillary(p) - pillarwid(p) / 3)-(px, pillary(p)), _RGB32(pr, pg, pb)
Next
End If
If Rnd * 6 < 4.8 Then
For px = pillarx(p) - (pillarwid(p) + pillarwid(p) / 5) To pillarx(p) + pillarwid(p) + pillarwid(p) / 5
Line (px, pillary(p) + pillarh(p))-(px, pillary(p) + pillarh(p) + pillarwid(p) / 3), _RGB32(pr, pg, pb)
Next
End If
For px = pillarx(p) + 1 To pillarx(p) - (pillarx(wid) - 1) Step -1
tpr = pr - n / 3: tpg = pg - n / 3: tpb = pb - n / 3
If tpr < 2 Then tpr = 2
If tpg < 2 Then tpg = 2
If tpb < 2 Then tpb = 2
Line (px, pillary(p))-(px, pillary(p) + pillarh(p)), _RGB32(tpr, tpg, tpb)
Next
tpr = pr + 40: tpg = pg + 40: tpb = pb + 40
If tpr > 254 Then tpr = 254
If tpg > 254 Then tpg = 254
If tpb > 254 Then tpb = 254
pcl = 3 + pillarwid(p) / 6
For px = pillarx(p) - pillarwid(p) To pillarx(p) + pillarwid(p) Step pcl
tpr = tpr + 2: tpg = tpg + 2: tpb = tpb + 2
If tpr > 254 Then tpr = 254
If tpg > 254 Then tpg = 254
If tpb > 254 Then tpb = 254
Line (px, pillary(p))-(px, pillary(p) + pillarh(p)), _RGB32(tpr, tpg, tpb)
Next
Next
'pyramids
pc2 = Int(1 + Rnd * 4)
For p = 1 To pc2
checkpyramids:
pyramidx(p) = 100 + Rnd * 3300
pyramidy(p) = 100 + Rnd * 2300
For check = 0 To 20
If housex(check) > pyramidx(p) - 250 And housex(check) < pyramidx(p) + 250 And housey(check) > pyramidy(p) - 250 And housey(check) < pyramidy(p) + 250 Then GoTo checkpyramids:
If hospitalx(check) > pyramidx(p) - 250 And hospitalx(check) < pyramidx(p) + 250 And hospitaly(check) > pyramidy(p) - 250 And hospitaly(check) < pyramidy(p) + 250 Then GoTo checkpyramids:
If armorx(check) > pyramidx(p) - 250 And armorx(check) < pyramidx(p) + 250 And armory(check) > pyramidy(p) - 250 And armory(check) < pyramidy(p) + 250 Then GoTo checkpyramids:
Next check
For check = 0 To pc
If pillarx(check) > pyramidx(p) - 250 And pillarx(check) < pyramidx(p) + 250 And pillary(check) > pyramidy(p) - 250 And pillary(check) < pyramidy(p) + 250 Then GoTo checkpyramids:
Next check
For check = 0 To 30
If lx(check) > pyramidx(p) - 250 And lx(check) < pyramidx(p) + 250 And ly(check) > pyramidy(p) - 250 And ly(check) < pyramidy(p) + 250 Then GoTo checkpyramids:
Next check
pyramidh(p) = Int(Rnd * 120) + 60
pr = Rnd * 255: pg = Rnd * 255: pb = Rnd * 255
For n = 0 To pyramidh(p)
Line (pyramidx(p) - n, pyramidy(p) + n)-(pyramidx(p) + n, pyramidy(p) + n), _RGB32(pr, pg, pb), BF
tpr = pr - n / 2: tpg = pg = n / 2: tpb = pb - n / 3
If tpr < 2 Then tpr = 2
If tpg < 2 Then tpg = 2
If tpb < 2 Then tpb = 2
Line (pyramidx(p) - (n - 1), pyramidy(p) + n)-(pyramidx(p), pyramidy(p) + n), _RGB32(tpr, tpg, tpb), BF
Next n
Next p
'Cave
again3:
cavex = (Rnd * 2700) + 1000
cavey = (Rnd * 2000) + 500
If chk = 1 Then GoTo again4:
For check = 0 To 30
If housex(check) > cavex - 650 And housex(check) < cavex + 650 And housey(check) > cavey - 650 And housey(check) < cavey + 650 Then GoTo again3:
If hospitalx(check) > cavex - 650 And hospitalx(check) < cavex + 650 And hospitaly(check) > cavey - 650 And hospitaly(check) < cavey + 650 Then GoTo again3:
If armorx(check) > cavex - 650 And armorx(check) < cavex + 650 And armory(check) > cavey - 650 And armory(check) < cavey + 650 Then GoTo again3:
Next check
again4:
For check2 = 0 To 30
If lx(check2) > cavex - 450 And lx(check2) < cavex + 450 And ly(check2) > cavey - 450 And ly(check2) < cavey + 450 Then chk = 1: GoTo again3:
Next check2
chk = 0
For sz = 1 To 100 Step .25
cl = cl + .25
Circle (cavex, cavey), sz, _RGB32(220 - cl, 100 - cl, 100 - cl), 2 * _Pi, _Pi, 1
Next sz
cl = 0
For sz = 1 To 30 Step .25
Circle (cavex, cavey), sz, _RGB32(0, 0, 0), 2 * _Pi, _Pi, 1
Next sz
End If
If level = 5 Then
_AutoDisplay
_PrintString (210, 160), "Congratulations, you saved the town!!"
_PrintString (210, 210), "Would you like to play again? (Y/N)"
Do
a$ = InKey$
If a$ = "y" Or a$ = "Y" Then GoTo begin:
If a$ = "n" Or a$ = "N" Then End
Loop
End If
If town = 2 Then
alreadydone = 0
level = level + 1
Line (0, 0)-(4000, 3000), _RGB32(Rnd * 150, Rnd * 150, Rnd * 150), BF
'Texture
For texture = 1 To 200000
tx = Rnd * 4000
ty = Rnd * 3000
Circle (tx, ty), 1, _RGB32(0, 255, 255)
Next texture
For h2 = 0 To 20
housex(h2) = -100
housey(h2) = -100
hospitalx(h2) = -100
hospitaly(h2) = -100
armorx(h2) = -100
armory(h2) = -100
Next h2
cavex = -100
cavey = -100
For diamonds = 1 To 300
xx = Rnd * 4000
yy = Rnd * 3000
size = Int(Rnd * 300) + 20
c1 = (Rnd * 155) + 100
c2 = (Rnd * 155) + 100
c3 = (Rnd * 155) + 100
For a = 0 To size / 2
Line (xx + a, yy + a)-(xx - a, yy + a), _RGB32(c1, c2, c3)
Next a
For b = size / 2 To 0 Step -1
Line (xx + b, yy - b + size)-(xx - b, yy - b + size), _RGB32(c1, c2, c3)
Next b
Next diamonds
drax = (3000 * Rnd) + 500
dray = (2000 * Rnd) + 500
drag = 200 + (level * 20)
End If
'_Dest 0
'_Source map
playerSpeed = 6
_Dest 0
_Source map
t = 1
Do
Cls
_Limit 60
_PutImage (camera.x, camera.y), map
_Title "Gold " + Str$(gold) + " Health " + Str$(health) + " Armor " + Str$(armor)
While _MouseInput: Wend
mousex = _MouseX
mousey = _MouseY
'Sword
swordx = player.x + camera.x + lhandx
swordy = player.y + camera.y + lhandy
'Thanks to B+ for most of this mouse-moving sword!
a = _Atan2(mousey - swordy, mousex - swordx)
For swl = 1 To 75 Step 15
sc1 = Int(Rnd * 180) + 75
sc2 = Int(Rnd * 180) + 75
sc3 = Int(Rnd * 180) + 75
sx = swordx + swl * Cos(a)
sy = swordy + swl * Sin(a)
Line (swordx, swordy)-(sx, sy), _RGB32(sc1, sc2, sc3)
Line (swordx + 1, swordy + 1)-(sx + 1, sy + 1), _RGB32(sc1, sc2, sc3)
Line (swordx - 1, swordy - 1)-(sx - 1, sy - 1), _RGB32(sc1, sc2, sc3)
Next swl
dy = 0
dx = 0
If mousey < player.y + camera.y - 5 Then dy = -1
If mousey > player.y + camera.y + 5 Then dy = 1
If mousex < player.x + camera.x - 5 Then dx = -1
If mousex > player.x + camera.x + 5 Then dx = 1
For ch = 1 To 30
If player.x > housex(ch) And player.x < housex(ch) + housex2(ch) And player.y > housey(ch) - (housex2(ch) / 2) And player.y < housey(ch) + housey2(ch) Then
location:
player.x = (player.x) + (Rnd * 150)
player.y = (player.y) + (Rnd * 150)
For check = 0 To 30
If housex(check) > player.x - 250 And housex(check) < player.x + 250 And housey(check) > player.y - 250 And housey(check) < player.y + 250 Then GoTo location:
Next check
_AutoDisplay
Color _RGB32(0, 0, 0), _RGB32(255, 255, 255)
If ch = 16 Or ch = 19 Then
If cavex + camera.x > player.x + camera.x Then _PrintString (210, 210), "The Cave is East of here."
If cavex + camera.x < player.x + camera.x Then _PrintString (210, 210), "The Cave is West of here."
GoTo skipthem:
End If
If ch = 17 Or ch = 20 Then
If cavey + camera.y > player.y + camera.y Then _PrintString (210, 210), "The Cave is South of here."
If cavey + camera.y < player.y + camera.y Then _PrintString (210, 210), "The Cave is North of here."
GoTo skipthem:
End If
If ch = 1 Then _PrintString (210, 210), "Beware of the dragons!"
If ch = 2 Then _PrintString (210, 210), "Save this town!"
If ch = 3 Then _PrintString (210, 210), "Are you brave enough?"
If ch = 4 Then _PrintString (210, 210), "King Arthur tried to save us, but couldn't."
If ch = 5 Then _PrintString (210, 210), "Your sword will get stronger at the Armory!"
If ch = 6 Then _PrintString (210, 210), "Heal up at a hospital."
If ch = 7 Then _PrintString (210, 210), "You save the town after 5 levels."
If ch = 8 Then _PrintString (210, 210), "The dragons breathe fire."
If ch = 9 Then _PrintString (210, 210), "You can only use the Armory once per level for 10 gold pieces each."
If ch = 10 Then _PrintString (210, 210), "Health costs 1 gold piece each at a hospital."
If ch = 11 Then _PrintString (210, 210), "You get random gold after each dragon."
If ch = 12 Then _PrintString (210, 210), "You cannot get hurt if you touch a dragon."
If ch = 13 Then _PrintString (210, 210), "Every level has a slightly different town and cave."
If ch = 14 Then _PrintString (210, 210), "The dragons get harder when you go to the next cave."
If ch = 15 Then _PrintString (210, 210), "Sit down and have a meal with us."
If ch = 18 Then _PrintString (210, 210), "Sorry, no WiFi here."
skipthem:
Color _RGB32(255, 255, 255), _RGB32(0, 0, 0)
Do
While _MouseInput: Wend
mouseLeftButton = _MouseButton(1)
If mouseLeftButton Then
Clear_MB 1
GoTo continue:
End If
Loop
End If
continue:
Next ch
For ch = 1 To 5
If player.x > hospitalx(ch) And player.x < hospitalx(ch) + hospitalx2(ch) And player.y > hospitaly(ch) - (hospitalx2(ch) / 2) And player.y < hospitaly(ch) + hospitaly2(ch) Then
location2:
player.x = (player.x) + (Rnd * 150)
player.y = (player.y) + (Rnd * 150)
For check = 0 To 30
If hospitalx(check) > player.x - 250 And hospitalx(check) < player.x + 250 And hospitaly(check) > player.y - 250 And hospitaly(check) < player.y + 250 Then GoTo location2:
Next check
If health = besthealth Then GoTo skiphealth:
neededhealth = besthealth - health
gold = gold - neededhealth
If gold < 0 Then
neededhealth = neededhealth + gold
gold = 0
End If
health = health + neededhealth
For snd = 500 To 800 Step 100
Sound snd, .5
Next snd
skiphealth:
End If
Next ch
For ch = 1 To 5
If player.x > armorx(ch) And player.x < armorx(ch) + armorx2(ch) And player.y > armory(ch) - (armorx2(ch) / 2) And player.y < armory(ch) + armory2(ch) Then
location3:
player.x = (player.x) + (Rnd * 150)
player.y = (player.y) + (Rnd * 150)
For check = 0 To 30
If armorx(check) > player.x - 250 And armorx(check) < player.x + 250 And armory(check) > player.y - 250 And armory(check) < player.y + 250 Then GoTo location3:
Next check
If alreadydone = 1 Then GoTo skiparmor:
If gold < 10 Then GoTo skiparmor:
gold = gold - 10
armor = armor + 10
For snd = 500 To 800 Step 100
Sound snd, .5
Next snd
alreadydone = 1
skiparmor:
End If
Next ch
'Check to see if you have went into the town cave.
If player.x > cavex - 100 And player.x < cavex + 5 And player.y > cavey - 100 And player.y < cavey + 5 Then town = 2: GoTo start:
more2:
If dy = -1 Then player.y = player.y - (playerSpeed / 2): t = t + 1
If dy = 1 Then player.y = player.y + (playerSpeed / 2): t = t + 1
If dx = -1 Then player.x = player.x - (playerSpeed / 2): t = t + 1
If dx = 1 Then player.x = player.x + (playerSpeed / 2): t = t + 1
If _KeyDown(ESC) Then End
If player.x < 0 Then player.x = 0
If player.x > _Width(map) Then player.x = _Width(map)
If player.y < 0 Then player.y = 0
If player.y > _Height(map) Then player.y = _Height(map)
adjustCamera
'Draw Head
For sz = .25 To 10 Step .25
Circle (player.x + camera.x, player.y + camera.y), sz, _RGB32(255, 166, 127)
Next sz
'Draw Smile
Circle (player.x + camera.x, player.y + camera.y + 2), 7, _RGB32(255, 0, 0), _Pi, 2 * _Pi, .5
'Draw Eyes
Circle (player.x + camera.x - 4, player.y + camera.y - 2), 1, _RGB32(0, 0, 255)
Circle (player.x + camera.x + 4, player.y + camera.y - 2), 1, _RGB32(0, 0, 255)
'hat
Line (player.x + camera.x - 10, player.y + camera.y - 10)-(player.x + camera.x + 10, player.y + camera.y - 9), _RGB32(155, 0, 0), BF
Line (player.x + camera.x - 5, player.y + camera.y - 9)-(player.x + camera.x + 5, player.y + camera.y - 15), _RGB32(155, 0, 0), BF
'Body
Line (player.x + camera.x - 10, player.y + camera.y + 10)-(player.x + camera.x + 10, player.y + camera.y + 40), _RGB32(155, 0, 0), BF
If t > 24 Then t = 1
If t > 0 And t < 12 Then
lhandx = 20: lhandy = 30
'Left Arm
For wid2 = .1 To 3 Step .1
Line (player.x + camera.x - 10 - wid2, player.y + camera.y + 10)-(player.x + camera.x - 20 - wid2, player.y + camera.y + 30), _RGB32(255, 166, 127)
Next wid2
'Right Arm
For wid1 = .1 To 3 Step .1
Line (player.x + camera.x + 10 + wid1, player.y + camera.y + 10)-(player.x + camera.x + 20 + wid1, player.y + camera.y + 30), _RGB32(255, 166, 127)
Next wid1
'Left leg
For wid2 = .1 To 3 Step .1
Line (player.x + camera.x - 10 + wid2, player.y + camera.y + 40)-(player.x + camera.x - 10 + wid2, player.y + camera.y + 60), _RGB32(255, 166, 127)
Next wid2
'Right leg
For wid1 = .1 To 3 Step .1
Line (player.x + camera.x + 10 - wid1, player.y + camera.y + 40)-(player.x + camera.x + 10 - wid1, player.y + camera.y + 60), _RGB32(255, 166, 127)
Next wid1
End If
If t > 11 And t < 25 Then
lhandx = 30: lhandy = 30
'Left Arm
For wid2 = .1 To 3 Step .1
Line (player.x + camera.x - 10 - wid2, player.y + camera.y + 10)-(player.x + camera.x - 30 - wid2, player.y + camera.y + 30), _RGB32(255, 166, 127)
Next wid2
'Right Arm
For wid1 = .1 To 3 Step .1
Line (player.x + camera.x + 10 + wid1, player.y + camera.y + 10)-(player.x + camera.x + 30 + wid1, player.y + camera.y + 30), _RGB32(255, 166, 127)
Next wid1
'Left leg
For wid2 = .1 To 3 Step .1
Line (player.x + camera.x - 10 + wid2, player.y + camera.y + 40)-(player.x + camera.x - 15 + wid2, player.y + camera.y + 60), _RGB32(255, 166, 127)
Next wid2
'Right leg
For wid1 = .1 To 3 Step .1
Line (player.x + camera.x + 10 - wid1, player.y + camera.y + 40)-(player.x + camera.x + 15 - wid1, player.y + camera.y + 60), _RGB32(255, 166, 127)
Next wid1
End If
If town = 2 Then
If drag < 1 Then GoTo nex:
'Draw Dragon
If player.x > drax Then drax = drax + 1
If player.x < drax Then drax = drax - 1
If player.y > dray Then dray = dray + 1
If player.y < dray Then dray = dray - 1
If drax > 3950 Then drax = 3950
If drax < 25 Then drax = 25
If dray > 2930 Then dray = 2930
If dray < 25 Then dray = 25
'Face
For sz = .25 To 30 Step .25
Circle (drax + camera.x, dray + camera.y), sz, _RGB32(255, 0, 0)
Next sz
'Eyes
For sz = .25 To 6 Step .25
Circle (drax - 15 + camera.x, dray - 15 + camera.y), sz, _RGB32(0, 0, 0)
Next sz
For sz = .25 To 6 Step .25
Circle (drax + 15 + camera.x, dray - 15 + camera.y), sz, _RGB32(0, 0, 0)
Next sz
'Thanks to OldMoses for most of this eye-following code.
xh% = drax - 15
yh% = dray - 15
xh2% = drax + 15
yh2% = dray - 15
dx% = player.x - xh%
dy% = player.y - yh%
mag! = _Hypot(dx%, dy%)
If mag! = 0 Then
ux! = 0: uy! = 0
Else
ux! = dx% / mag! '
uy! = dy% / mag! '
End If
spx! = ux! * 5
spy! = uy! * 5
For sz = .25 To 3.5 Step .25
Circle (xh% + spx! + camera.x, yh% + spy! + camera.y), sz, _RGB32(255, 255, 255)
Next sz
For sz = .25 To 3.5 Step .25
Circle (xh2% + spx! + camera.x, yh2% + spy! + camera.y), sz, _RGB32(255, 255, 255)
Next sz
'Mouth
For sz = .25 To 10 Step .25
Circle (drax + camera.x, dray + 15 + camera.y), sz, _RGB32(255, 255, 255), , , .5
Next sz
'body
Line (drax + camera.x, dray + 30 + camera.y)-(drax + 100 + camera.x, dray + 50 + camera.y), _RGB32(255, 0, 0), BF
For a = 0 To 15
Line (drax + a + camera.x + 30, dray + a + camera.y + 15)-(drax - a + camera.x + 30, dray + a + camera.y + 15), _RGB32(255, 0, 0)
Next a
For a = 0 To 15
Line (drax + a + camera.x + 45, dray + a + camera.y + 15)-(drax - a + camera.x + 45, dray + a + camera.y + 15), _RGB32(255, 0, 0)
Next a
For a = 0 To 15
Line (drax + a + camera.x + 60, dray + a + camera.y + 15)-(drax - a + camera.x + 60, dray + a + camera.y + 15), _RGB32(255, 0, 0)
Next a
For a = 0 To 15
Line (drax + a + camera.x + 75, dray + a + camera.y + 15)-(drax - a + camera.x + 75, dray + a + camera.y + 15), _RGB32(255, 0, 0)
Next a
'Dragon Health
_PrintString (drax + camera.x + 35, dray + camera.y + 35), Str$(drag)
'Nose
For sz = .25 To 2 Step .25
Circle (drax - 3 + camera.x, dray + camera.y), sz, _RGB32(255, 255, 255)
Circle (drax + 3 + camera.x, dray + camera.y), sz, _RGB32(255, 255, 255)
Next sz
'Ears
For a = 0 To 15
Line (drax + a + camera.x - 7, dray + a + camera.y - 38)-(drax - a + camera.x - 7, dray + a + camera.y - 38), _RGB32(255, 0, 0)
Next a
For a = 0 To 15
Line (drax + a + camera.x + 7, dray + a + camera.y - 38)-(drax - a + camera.x + 7, dray + a + camera.y - 38), _RGB32(255, 0, 0)
Next a
'legs
Line (drax + camera.x, dray + 50 + camera.y)-(drax + 10 + camera.x, dray + 80 + camera.y), _RGB32(255, 0, 0), BF
Line (drax + 25 + camera.x, dray + 50 + camera.y)-(drax + 35 + camera.x, dray + 80 + camera.y), _RGB32(255, 0, 0), BF
Line (drax + 65 + camera.x, dray + 50 + camera.y)-(drax + 75 + camera.x, dray + 80 + camera.y), _RGB32(255, 0, 0), BF
Line (drax + 90 + camera.x, dray + 50 + camera.y)-(drax + 100 + camera.x, dray + 80 + camera.y), _RGB32(255, 0, 0), BF
'Tail
a = 1
For tt = 1 To 100
s = 0
a = a - .5
If a < -33 Then a = 1
For d = 0 To a Step -.125
s = s + 1
x3 = Cos(s * 3.141592 / 180) * d
y3 = Sin(s * 3.151492 / 180) * d
Circle (x3 + drax + 100 + camera.x, y3 + dray + 40 + camera.y), 2, _RGB32(255, 0, 0)
Next d
Next tt
fire = Rnd * 100
If fire > 98 Then
firex = drax
firey = dray
For flame = .5 To 20 Step .25
If drax + camera.x > player.x + camera.x Then
firex = firex - 5
End If
If drax + camera.x < player.x + camera.x Then
firex = firex + 5
End If
If dray + camera.y > player.y + camera.y Then
firey = firey - 5
End If
If dray + camera.y < player.y + camera.y Then
firey = firey + 5
End If
For sz = .25 To flame Step .25
Circle (firex + camera.x, firey + camera.y), flame, _RGB32(255, 0, 0)
Next sz
If firex + camera.x > player.x - 20 + camera.x And firex + camera.x < player.x + 20 + camera.x And firey + camera.y > player.y + camera.y - 20 And firey + camera.y < player.y + camera.y + 20 Then
health = health - 1
player.x = (player.x) + (Rnd * 20)
player.y = (player.y) + (Rnd * 20)
_Delay .02
If health < 1 Then
_AutoDisplay
For snd = 600 To 300 Step -50
Sound snd, .5
Next snd
Locate 15, 25: Print "G A M E O V E R"
Locate 18, 25: Print "Again? (Y/N)"
Do
a$ = InKey$
If a$ = "y" Or a$ = "Y" Then GoTo begin:
If a$ = "n" Or a$ = "N" Then End
Loop
End If
GoTo nex:
End If
_Display
Next flame
End If
nex:
'Check to see if you hit the monster.
If sx > drax + camera.x - 20 And sx < drax + 20 + camera.x And sy > dray - 20 + camera.y And sy < dray + 20 + camera.y Then
drag = drag - armor
If drag < 1 Then
drax = -100
dray = -100
gold = gold + (Int(Rnd * 400) + 100)
For snd = 100 To 700 Step 50
Sound snd, 1
Next snd
If drag < 1 And drag2 < 1 Then
_Delay 1
town = 1
GoTo start:
End If
End If
_Delay .02
End If
End If
_Display
Loop
Sub adjustCamera
If player.x + camera.x > _Width / 2 Or player.x + camera.x < _Width / 2 Then
camera.x = _Width / 2 - player.x
End If
If camera.x > 0 Then camera.x = 0
If camera.x < -(_Width(map) - _Width) Then camera.x = -(_Width(map) - _Width)
If player.y + camera.y > _Height / 2 Or player.y + camera.y < _Height / 2 Then
camera.y = _Height / 2 - player.y
End If
If camera.y > 0 Then camera.y = 0
If camera.y < -(_Height(map) - _Height) Then camera.y = -(_Height(map) - _Height)
End Sub
Sub Clear_MB (var As Integer)
Do Until Not _MouseButton(var)
While _MouseInput: Wend
Loop
End Sub 'Clear_MB
Posts: 263
Threads: 14
Joined: Apr 2022
Reputation:
23
08-17-2022, 11:56 PM
(This post was last modified: 08-18-2022, 12:24 AM by OldMoses.)
I got about 4-4.5% CPU usage and around 100MB memory usage. It never locked up on me, though, although I didn't run into any dragons. I guess I have more exploring to do. Looks good so far, but if there's a bug I didn't hit it.
EDIT: I've been in three caves and fought a dragon in each with no issues other than I have no way of knowing if I actually slew them. It just pops me back outside. It might be an issue with your computer, mine never locked up. Scratch that, on another go I locked up just as I was fighting a dragon. I think it was after the beeps that indicate victory.
DO: LOOP: DO: LOOP
sha_na_na_na_na_na_na_na_na_na:
Posts: 2,700
Threads: 124
Joined: Apr 2022
Reputation:
134
I got hung up om 2nd dragon.
b = b + ...
Posts: 263
Threads: 14
Joined: Apr 2022
Reputation:
23
Starting on line 725:
IF drag < 1 AND drag2 < 1 THEN
_DELAY 1
town = 1
GOTO start:
END IF
A couple of observations:
I did a search for drag2 and this is the only instance of it. drag2 will always be zero.
This IF...END IF block is within another one testing if drag < 1 {line 718} and is probably redundant.
Given that it is shunting the program flow back to 'start', could it be possible that it is jumping
around the _DISPLAY on line 734? Your program may not be locking up, but is rather stuck in a loop
where _DISPLAY is set and not being refreshed. Perhaps because drag is remaining below 1... not sure
I placed an _AUTODISPLAY after the 'start' on line 80, and played a lot farther, fighting a 300 power dragon.
Then the screen locked again.
DO: LOOP: DO: LOOP
sha_na_na_na_na_na_na_na_na_na:
Posts: 323
Threads: 46
Joined: Apr 2022
Reputation:
11
Thanks guys for trying it out. OldMoses, I took your advice and changed a couple lines. I also added an Autodisplay at the very beginning too for when people want to play again. I'll test it more soon, but here is the update:
Code: (Select All) 'Scrolling Map Example by SierraKen - August 15, 2022
'Thank you to Felippe, James D. Jarvis, mdijkens, Petr, and B+ for the help and inspiration!
Type object
x As Single
y As Single
End Type
Const ESC = 27
Dim Shared player As object
Dim Shared camera As object
Dim Shared map As Long
Dim mousex As Single, mousey As Single
Dim playerSpeed As Single
Dim housex(30)
Dim housey(30)
Dim housex2(30)
Dim housey2(30)
Dim hospitalx(30)
Dim hospitaly(30)
Dim hospitalx2(30)
Dim hospitaly2(30)
Dim armorx(30)
Dim armory(30)
Dim armorx2(30)
Dim armory2(30)
Dim lx(30)
Dim ly(30)
Dim cavex As Single, cavey As Single
Dim pillarx(30), pillary(30), pillarh(30), pillarwid(30)
Dim pyramidx(6), pyramidy(6), pyramidh(6)
Dim drag As Single
Dim drax As Single, dray As Single
Dim health As Single, town As Single, besthealth As Single, alreadydone As Single
Dim swordx As Single, swordy As Single, sx As Single, sy As Single
Dim gold As Single, armor As Single
Dim tx As Double, ty As Double
begin:
_Limit 60
_Title "Explorer - by Ken G"
_AutoDisplay
town = 1
health = 500
besthealth = 500
armor = 10
alreadydone = 0
Randomize Timer
Screen _NewImage(800, 600, 32)
Cls
Print: Print: Print
Print " Explorer"
Print
Print " by Ken G."
Print: Print
Print
Print " Use the mouse to move and to turn your sword."
Print " Use the left mouse button to clear messages."
Print " Press Esc to quit."
Print " The object of the game is to get gold while"
Print " destroying the monsters."
Print " Passing 5 caves (levels) wins the game."
Print: Print
Print " Left Click the Screen With Your Mouse To Start."
Do
_Limit 60
While _MouseInput: Wend
mouseLeftButton = _MouseButton(1)
If mouseLeftButton Then
Clear_MB 1
GoTo start:
End If
Loop
start:
_Limit 60
_AutoDisplay
player.x = _Width / 2
player.y = _Height / 2
If map <> 0 Then _FreeImage (map)
map = _NewImage(_Width * 5, _Height * 5, 32)
_Dest map
If town = 1 Then
Cls
'Grass
Line (0, 0)-(4000, 3000), _RGB32(0, 127, 0), BF
'Texture
For texture = 1 To 200000
tx = Rnd * 4000
ty = Rnd * 3000
Circle (tx, ty), 1, _RGB32(155, 166, 127)
Next texture
'Houses
For h = 1 To 20
again:
housex(h) = Rnd * 3500
housey(h) = Rnd * 2500
For check = 0 To h - 1
If housex(check) > housex(h) - 250 And housex(check) < housex(h) + 250 And housey(check) > housey(h) - 250 And housey(check) < housey(h) + 250 Then GoTo again:
Next check
housex2(h) = (Rnd * 100) + 50
housey2(h) = (Rnd * 100) + 50
'House
Line (housex(h), housey(h))-(housex(h) + housex2(h), housey(h) + housey2(h)), _RGB32(Rnd * 255, Rnd * 255, Rnd * 255), BF
'Roof
For sz = .25 To (housex2(h) / 2) Step .1
Circle (housex(h) + (housex2(h) / 2), housey(h)), sz, _RGB32(150, 75, 50), 2 * _Pi, _Pi, 1
Next sz
Line (housex(h) + (housex2(h) / 2) - 10, housey(h) + (housey2(h) - 20))-(housex(h) + (housex2(h) / 2) + 10, housey(h) + housey2(h)), _RGB32(128, 116, 128), BF
'Windows
For w = 0 To housey2(h) - 45 Step 15
Line (housex(h) + (housex2(h) / 2) - housex2(h) / 4, housey(h) + (housey2(h) - 35 - w))-(housex(h) + (housex2(h) / 2) - ((housex2(h) / 4) + 10), housey(h) + housey2(h) - 25 - w), _RGB32(128, 116, 128), BF
Line (housex(h) + (housex2(h) / 2) + housex2(h) / 4, housey(h) + (housey2(h) - 35 - w))-(housex(h) + (housex2(h) / 2) + ((housex2(h) / 4) + 10), housey(h) + housey2(h) - 25 - w), _RGB32(128, 116, 128), BF
Next w
Next h
'Hospitals
For ho = 1 To 5
ag:
hospitalx(ho) = Rnd * 3500
hospitaly(ho) = Rnd * 2500
For check = 0 To ho - 1
If housex(check) > hospitalx(ho) - 250 And housex(check) < hospitalx(ho) + 250 And housey(check) > hospitaly(ho) - 250 And housey(check) < hospitaly(ho) + 250 Then GoTo ag:
Next check
hospitalx2(ho) = (Rnd * 100) + 50
hospitaly2(ho) = (Rnd * 100) + 50
'House
Line (hospitalx(ho), hospitaly(ho))-(hospitalx(ho) + hospitalx2(ho), hospitaly(ho) + hospitaly2(ho)), _RGB32(255, 0, 0), BF
'Cross
Line (hospitalx(ho) + (hospitalx2(ho) / 2), hospitaly(ho) + 5)-(hospitalx(ho) + (hospitalx2(ho) / 2), hospitaly(ho) + 20), _RGB32(255, 255, 255)
Line (hospitalx(ho) + (hospitalx2(ho) * .4), hospitaly(ho) + 10)-(hospitalx(ho) + (hospitalx2(ho) * .6), hospitaly(ho) + 10), _RGB32(255, 255, 255)
'Roof
For sz = .25 To (hospitalx2(ho) / 2) Step .1
Circle (hospitalx(ho) + (hospitalx2(ho) / 2), hospitaly(ho)), sz, _RGB32(150, 75, 50), 2 * _Pi, _Pi, 1
Next sz
Line (hospitalx(ho) + (hospitalx2(ho) / 2) - 10, hospitaly(ho) + (hospitaly2(ho) - 20))-(hospitalx(ho) + (hospitalx2(ho) / 2) + 10, hospitaly(ho) + hospitaly2(ho)), _RGB32(128, 116, 128), BF
'Windows
For w = 0 To hospitaly2(ho) - 45 Step 15
Line (hospitalx(ho) + (hospitalx2(ho) / 2) - hospitalx2(ho) / 4, hospitaly(ho) + (hospitaly2(ho) - 35 - w))-(hospitalx(ho) + (hospitalx2(ho) / 2) - ((hospitalx2(ho) / 4) + 10), hospitaly(ho) + hospitaly2(ho) - 25 - w), _RGB32(128, 116, 128), BF
Line (hospitalx(ho) + (hospitalx2(ho) / 2) + hospitalx2(ho) / 4, hospitaly(ho) + (hospitaly2(ho) - 35 - w))-(hospitalx(ho) + (hospitalx2(ho) / 2) + ((hospitalx2(ho) / 4) + 10), hospitaly(ho) + hospitaly2(ho) - 25 - w), _RGB32(128, 116, 128), BF
Next w
Next ho
'Armories
For h = 1 To 5
agn:
armorx(h) = Rnd * 3500
armory(h) = Rnd * 2500
For check = 0 To h - 1
If housex(check) > armorx(h) - 150 And housex(check) < armorx(h) + 150 And housey(check) > armory(h) - 225 And housey(check) < armory(h) + 225 Then GoTo agn:
If hospitalx(check) > armorx(h) - 150 And hospitalx(check) < armorx(h) + 150 And hospitaly(check) > armory(h) - 225 And hospitaly(check) < armory(h) + 225 Then GoTo agn:
Next check
armorx2(h) = 125
armory2(h) = 125
'House
Line (armorx(h), armory(h))-(armorx(h) + armorx2(h), armory(h) + armory2(h)), _RGB32(0, 255, 0), BF
Color _RGB32(255, 0, 0), _RGB32(0, 255, 0)
_PrintString (armorx(h) + 40, armory(h) + 7), "Armory"
'Roof
For sz = .25 To (armorx2(h) / 2) Step .1
Circle (armorx(h) + (armorx2(h) / 2), armory(h)), sz, _RGB32(150, 75, 50), 2 * _Pi, _Pi, 1
Next sz
Line (armorx(h) + (armorx2(h) / 2) - 10, armory(h) + (armory2(h) - 20))-(armorx(h) + (armorx2(h) / 2) + 10, armory(h) + armory2(h)), _RGB32(128, 116, 128), BF
'Windows
For w = 0 To armory2(h) - 45 Step 15
Line (armorx(h) + (armorx2(h) / 2) - armorx2(h) / 4, armory(h) + (armory2(h) - 35 - w))-(armorx(h) + (armorx2(h) / 2) - ((armorx2(h) / 4) + 10), armory(h) + armory2(h) - 25 - w), _RGB32(128, 116, 128), BF
Line (armorx(h) + (armorx2(h) / 2) + armorx2(h) / 4, armory(h) + (armory2(h) - 35 - w))-(armorx(h) + (armorx2(h) / 2) + ((armorx2(h) / 4) + 10), armory(h) + armory2(h) - 25 - w), _RGB32(128, 116, 128), BF
Next w
Next h
Color _RGB32(255, 255, 255), _RGB32(0, 0, 0)
'Lakes
For rr = 1 To 30
again2:
lx(rr) = Rnd * 4000
ly(rr) = Rnd * 3000
For check = 0 To rr - 1
If lx(check) > lx(rr) - 250 And lx(check) < lx(rr) + 250 And ly(check) > ly(rr) - 250 And ly(check) < ly(rr) + 250 Then GoTo again2:
Next check
For check = 0 To 30
If housex(check) > lx(rr) - 250 And housex(check) < lx(rr) + 250 And housey(check) > ly(rr) - 250 And housey(check) < ly(rr) + 250 Then GoTo again2:
If hospitalx(check) > lx(rr) - 250 And hospitalx(check) < lx(rr) + 250 And hospitaly(check) > ly(rr) - 250 And hospitaly(check) < ly(rr) + 250 Then GoTo again2:
If armorx(check) > lx(rr) - 250 And armorx(check) < lx(rr) + 250 And armory(check) > ly(rr) - 250 And armory(check) < ly(rr) + 250 Then GoTo again2:
Next check
size = Int(Rnd * 150) + 20
shape = Rnd + .2
cl = 50
For sz = size To .25 Step -.25
cl = cl + .25
Circle (lx(rr), ly(rr)), sz, _RGB32(0, 0, cl + 50), , , shape
Next sz
cl = 0
Next rr
'pillars
pc = Int(11 + Rnd * 20)
For p = 1 To pc
checkpillars:
pillarx(p) = 100 + Rnd * 3300
pillary(p) = 100 + Rnd * 2300
For check = 0 To 20
If housex(check) > pillarx(p) - 250 And housex(check) < pillarx(p) + 250 And housey(check) > pillary(p) - 250 And housey(check) < pillary(p) + 250 Then GoTo checkpillars:
If hospitalx(check) > pillarx(p) - 250 And hospitalx(check) < pillarx(p) + 250 And hospitaly(check) > pillary(p) - 250 And hospitaly(check) < pillary(p) + 250 Then GoTo checkpillars:
If armorx(check) > pillarx(p) - 250 And armorx(check) < pillarx(p) + 250 And armory(check) > pillary(p) - 250 And armory(check) < pillary(p) + 250 Then GoTo checkpillars:
Next check
For check = 0 To 30
If lx(check) > pillarx(p) - 250 And lx(check) < pillarx(p) + 250 And ly(check) > pillary(p) - 250 And ly(check) < pillary(p) + 250 Then GoTo checkpillars:
Next check
pillarwid(p) = 4 + Int(Rnd * 20)
pillarh(p) = pillarwid(p) + Int(Rnd * (6 * pillarwid(p)))
pr = 30 + Rnd * 200: pg = 30 + Rnd * 200: pb = 30 + Rnd * 200
For px = pillarx(p) - pillarwid(p) To pillarx(p) + pillarwid(p)
Line (px, pillary(p))-(px, pillary(p) + pillarh(p)), _RGB32(pr, pg, pb)
Next
If Rnd * 6 > 2.5 Then
For px = pillarx(p) - (pillarwid(p) + pillarwid(p) / 5) To pillarx(p) + pillarwid(p) + pillarwid(p) / 5
Line (px, pillary(p) - pillarwid(p) / 3)-(px, pillary(p)), _RGB32(pr, pg, pb)
Next
End If
If Rnd * 6 < 4.8 Then
For px = pillarx(p) - (pillarwid(p) + pillarwid(p) / 5) To pillarx(p) + pillarwid(p) + pillarwid(p) / 5
Line (px, pillary(p) + pillarh(p))-(px, pillary(p) + pillarh(p) + pillarwid(p) / 3), _RGB32(pr, pg, pb)
Next
End If
For px = pillarx(p) + 1 To pillarx(p) - (pillarx(wid) - 1) Step -1
tpr = pr - n / 3: tpg = pg - n / 3: tpb = pb - n / 3
If tpr < 2 Then tpr = 2
If tpg < 2 Then tpg = 2
If tpb < 2 Then tpb = 2
Line (px, pillary(p))-(px, pillary(p) + pillarh(p)), _RGB32(tpr, tpg, tpb)
Next
tpr = pr + 40: tpg = pg + 40: tpb = pb + 40
If tpr > 254 Then tpr = 254
If tpg > 254 Then tpg = 254
If tpb > 254 Then tpb = 254
pcl = 3 + pillarwid(p) / 6
For px = pillarx(p) - pillarwid(p) To pillarx(p) + pillarwid(p) Step pcl
tpr = tpr + 2: tpg = tpg + 2: tpb = tpb + 2
If tpr > 254 Then tpr = 254
If tpg > 254 Then tpg = 254
If tpb > 254 Then tpb = 254
Line (px, pillary(p))-(px, pillary(p) + pillarh(p)), _RGB32(tpr, tpg, tpb)
Next
Next
'pyramids
pc2 = Int(1 + Rnd * 4)
For p = 1 To pc2
checkpyramids:
pyramidx(p) = 100 + Rnd * 3300
pyramidy(p) = 100 + Rnd * 2300
For check = 0 To 20
If housex(check) > pyramidx(p) - 250 And housex(check) < pyramidx(p) + 250 And housey(check) > pyramidy(p) - 250 And housey(check) < pyramidy(p) + 250 Then GoTo checkpyramids:
If hospitalx(check) > pyramidx(p) - 250 And hospitalx(check) < pyramidx(p) + 250 And hospitaly(check) > pyramidy(p) - 250 And hospitaly(check) < pyramidy(p) + 250 Then GoTo checkpyramids:
If armorx(check) > pyramidx(p) - 250 And armorx(check) < pyramidx(p) + 250 And armory(check) > pyramidy(p) - 250 And armory(check) < pyramidy(p) + 250 Then GoTo checkpyramids:
Next check
For check = 0 To pc
If pillarx(check) > pyramidx(p) - 250 And pillarx(check) < pyramidx(p) + 250 And pillary(check) > pyramidy(p) - 250 And pillary(check) < pyramidy(p) + 250 Then GoTo checkpyramids:
Next check
For check = 0 To 30
If lx(check) > pyramidx(p) - 250 And lx(check) < pyramidx(p) + 250 And ly(check) > pyramidy(p) - 250 And ly(check) < pyramidy(p) + 250 Then GoTo checkpyramids:
Next check
pyramidh(p) = Int(Rnd * 120) + 60
pr = Rnd * 255: pg = Rnd * 255: pb = Rnd * 255
For n = 0 To pyramidh(p)
Line (pyramidx(p) - n, pyramidy(p) + n)-(pyramidx(p) + n, pyramidy(p) + n), _RGB32(pr, pg, pb), BF
tpr = pr - n / 2: tpg = pg = n / 2: tpb = pb - n / 3
If tpr < 2 Then tpr = 2
If tpg < 2 Then tpg = 2
If tpb < 2 Then tpb = 2
Line (pyramidx(p) - (n - 1), pyramidy(p) + n)-(pyramidx(p), pyramidy(p) + n), _RGB32(tpr, tpg, tpb), BF
Next n
Next p
'Cave
again3:
cavex = (Rnd * 2700) + 1000
cavey = (Rnd * 2000) + 500
If chk = 1 Then GoTo again4:
For check = 0 To 30
If housex(check) > cavex - 650 And housex(check) < cavex + 650 And housey(check) > cavey - 650 And housey(check) < cavey + 650 Then GoTo again3:
If hospitalx(check) > cavex - 650 And hospitalx(check) < cavex + 650 And hospitaly(check) > cavey - 650 And hospitaly(check) < cavey + 650 Then GoTo again3:
If armorx(check) > cavex - 650 And armorx(check) < cavex + 650 And armory(check) > cavey - 650 And armory(check) < cavey + 650 Then GoTo again3:
Next check
again4:
For check2 = 0 To 30
If lx(check2) > cavex - 450 And lx(check2) < cavex + 450 And ly(check2) > cavey - 450 And ly(check2) < cavey + 450 Then chk = 1: GoTo again3:
Next check2
chk = 0
For sz = 1 To 100 Step .25
cl = cl + .25
Circle (cavex, cavey), sz, _RGB32(220 - cl, 100 - cl, 100 - cl), 2 * _Pi, _Pi, 1
Next sz
cl = 0
For sz = 1 To 30 Step .25
Circle (cavex, cavey), sz, _RGB32(0, 0, 0), 2 * _Pi, _Pi, 1
Next sz
End If
If level = 5 Then
_AutoDisplay
_PrintString (210, 160), "Congratulations, you saved the town!!"
_PrintString (210, 210), "Would you like to play again? (Y/N)"
Do
a$ = InKey$
If a$ = "y" Or a$ = "Y" Then GoTo begin:
If a$ = "n" Or a$ = "N" Then End
Loop
End If
If town = 2 Then
alreadydone = 0
level = level + 1
Line (0, 0)-(4000, 3000), _RGB32(Rnd * 150, Rnd * 150, Rnd * 150), BF
'Texture
For texture = 1 To 200000
tx = Rnd * 4000
ty = Rnd * 3000
Circle (tx, ty), 1, _RGB32(0, 255, 255)
Next texture
For h2 = 0 To 20
housex(h2) = -100
housey(h2) = -100
hospitalx(h2) = -100
hospitaly(h2) = -100
armorx(h2) = -100
armory(h2) = -100
Next h2
cavex = -100
cavey = -100
For diamonds = 1 To 300
xx = Rnd * 4000
yy = Rnd * 3000
size = Int(Rnd * 300) + 20
c1 = (Rnd * 155) + 100
c2 = (Rnd * 155) + 100
c3 = (Rnd * 155) + 100
For a = 0 To size / 2
Line (xx + a, yy + a)-(xx - a, yy + a), _RGB32(c1, c2, c3)
Next a
For b = size / 2 To 0 Step -1
Line (xx + b, yy - b + size)-(xx - b, yy - b + size), _RGB32(c1, c2, c3)
Next b
Next diamonds
drax = (3000 * Rnd) + 500
dray = (2000 * Rnd) + 500
drag = 200 + (level * 20)
End If
'_Dest 0
'_Source map
playerSpeed = 6
_Dest 0
_Source map
t = 1
Do
Cls
_Limit 60
_PutImage (camera.x, camera.y), map
_Title "Gold " + Str$(gold) + " Health " + Str$(health) + " Armor " + Str$(armor)
While _MouseInput: Wend
mousex = _MouseX
mousey = _MouseY
'Sword
swordx = player.x + camera.x + lhandx
swordy = player.y + camera.y + lhandy
'Thanks to B+ for most of this mouse-moving sword!
a = _Atan2(mousey - swordy, mousex - swordx)
For swl = 1 To 75 Step 15
sc1 = Int(Rnd * 180) + 75
sc2 = Int(Rnd * 180) + 75
sc3 = Int(Rnd * 180) + 75
sx = swordx + swl * Cos(a)
sy = swordy + swl * Sin(a)
Line (swordx, swordy)-(sx, sy), _RGB32(sc1, sc2, sc3)
Line (swordx + 1, swordy + 1)-(sx + 1, sy + 1), _RGB32(sc1, sc2, sc3)
Line (swordx - 1, swordy - 1)-(sx - 1, sy - 1), _RGB32(sc1, sc2, sc3)
Next swl
dy = 0
dx = 0
If mousey < player.y + camera.y - 5 Then dy = -1
If mousey > player.y + camera.y + 5 Then dy = 1
If mousex < player.x + camera.x - 5 Then dx = -1
If mousex > player.x + camera.x + 5 Then dx = 1
For ch = 1 To 30
If player.x > housex(ch) And player.x < housex(ch) + housex2(ch) And player.y > housey(ch) - (housex2(ch) / 2) And player.y < housey(ch) + housey2(ch) Then
location:
player.x = (player.x) + (Rnd * 150)
player.y = (player.y) + (Rnd * 150)
For check = 0 To 30
If housex(check) > player.x - 250 And housex(check) < player.x + 250 And housey(check) > player.y - 250 And housey(check) < player.y + 250 Then GoTo location:
Next check
_AutoDisplay
Color _RGB32(0, 0, 0), _RGB32(255, 255, 255)
If ch = 16 Or ch = 19 Then
If cavex + camera.x > player.x + camera.x Then _PrintString (210, 210), "The Cave is East of here."
If cavex + camera.x < player.x + camera.x Then _PrintString (210, 210), "The Cave is West of here."
GoTo skipthem:
End If
If ch = 17 Or ch = 20 Then
If cavey + camera.y > player.y + camera.y Then _PrintString (210, 210), "The Cave is South of here."
If cavey + camera.y < player.y + camera.y Then _PrintString (210, 210), "The Cave is North of here."
GoTo skipthem:
End If
If ch = 1 Then _PrintString (210, 210), "Beware of the dragons!"
If ch = 2 Then _PrintString (210, 210), "Save this town!"
If ch = 3 Then _PrintString (210, 210), "Are you brave enough?"
If ch = 4 Then _PrintString (210, 210), "King Arthur tried to save us, but couldn't."
If ch = 5 Then _PrintString (210, 210), "Your sword will get stronger at the Armory!"
If ch = 6 Then _PrintString (210, 210), "Heal up at a hospital."
If ch = 7 Then _PrintString (210, 210), "You save the town after 5 levels."
If ch = 8 Then _PrintString (210, 210), "The dragons breathe fire."
If ch = 9 Then _PrintString (210, 210), "You can only use the Armory once per level for 10 gold pieces each."
If ch = 10 Then _PrintString (210, 210), "Health costs 1 gold piece each at a hospital."
If ch = 11 Then _PrintString (210, 210), "You get random gold after each dragon."
If ch = 12 Then _PrintString (210, 210), "You cannot get hurt if you touch a dragon."
If ch = 13 Then _PrintString (210, 210), "Every level has a slightly different town and cave."
If ch = 14 Then _PrintString (210, 210), "The dragons get harder when you go to the next cave."
If ch = 15 Then _PrintString (210, 210), "Sit down and have a meal with us."
If ch = 18 Then _PrintString (210, 210), "Sorry, no WiFi here."
skipthem:
Color _RGB32(255, 255, 255), _RGB32(0, 0, 0)
Do
While _MouseInput: Wend
mouseLeftButton = _MouseButton(1)
If mouseLeftButton Then
Clear_MB 1
GoTo continue:
End If
Loop
End If
continue:
Next ch
For ch = 1 To 5
If player.x > hospitalx(ch) And player.x < hospitalx(ch) + hospitalx2(ch) And player.y > hospitaly(ch) - (hospitalx2(ch) / 2) And player.y < hospitaly(ch) + hospitaly2(ch) Then
location2:
player.x = (player.x) + (Rnd * 150)
player.y = (player.y) + (Rnd * 150)
For check = 0 To 30
If hospitalx(check) > player.x - 250 And hospitalx(check) < player.x + 250 And hospitaly(check) > player.y - 250 And hospitaly(check) < player.y + 250 Then GoTo location2:
Next check
If health = besthealth Then GoTo skiphealth:
neededhealth = besthealth - health
gold = gold - neededhealth
If gold < 0 Then
neededhealth = neededhealth + gold
gold = 0
End If
health = health + neededhealth
For snd = 500 To 800 Step 100
Sound snd, .5
Next snd
skiphealth:
End If
Next ch
For ch = 1 To 5
If player.x > armorx(ch) And player.x < armorx(ch) + armorx2(ch) And player.y > armory(ch) - (armorx2(ch) / 2) And player.y < armory(ch) + armory2(ch) Then
location3:
player.x = (player.x) + (Rnd * 150)
player.y = (player.y) + (Rnd * 150)
For check = 0 To 30
If armorx(check) > player.x - 250 And armorx(check) < player.x + 250 And armory(check) > player.y - 250 And armory(check) < player.y + 250 Then GoTo location3:
Next check
If alreadydone = 1 Then GoTo skiparmor:
If gold < 10 Then GoTo skiparmor:
gold = gold - 10
armor = armor + 10
For snd = 500 To 800 Step 100
Sound snd, .5
Next snd
alreadydone = 1
skiparmor:
End If
Next ch
'Check to see if you have went into the town cave.
If player.x > cavex - 100 And player.x < cavex + 5 And player.y > cavey - 100 And player.y < cavey + 5 Then town = 2: GoTo start:
more2:
If dy = -1 Then player.y = player.y - (playerSpeed / 2): t = t + 1
If dy = 1 Then player.y = player.y + (playerSpeed / 2): t = t + 1
If dx = -1 Then player.x = player.x - (playerSpeed / 2): t = t + 1
If dx = 1 Then player.x = player.x + (playerSpeed / 2): t = t + 1
If _KeyDown(ESC) Then End
If player.x < 0 Then player.x = 0
If player.x > _Width(map) Then player.x = _Width(map)
If player.y < 0 Then player.y = 0
If player.y > _Height(map) Then player.y = _Height(map)
adjustCamera
'Draw Head
For sz = .25 To 10 Step .25
Circle (player.x + camera.x, player.y + camera.y), sz, _RGB32(255, 166, 127)
Next sz
'Draw Smile
Circle (player.x + camera.x, player.y + camera.y + 2), 7, _RGB32(255, 0, 0), _Pi, 2 * _Pi, .5
'Draw Eyes
Circle (player.x + camera.x - 4, player.y + camera.y - 2), 1, _RGB32(0, 0, 255)
Circle (player.x + camera.x + 4, player.y + camera.y - 2), 1, _RGB32(0, 0, 255)
'hat
Line (player.x + camera.x - 10, player.y + camera.y - 10)-(player.x + camera.x + 10, player.y + camera.y - 9), _RGB32(155, 0, 0), BF
Line (player.x + camera.x - 5, player.y + camera.y - 9)-(player.x + camera.x + 5, player.y + camera.y - 15), _RGB32(155, 0, 0), BF
'Body
Line (player.x + camera.x - 10, player.y + camera.y + 10)-(player.x + camera.x + 10, player.y + camera.y + 40), _RGB32(155, 0, 0), BF
If t > 24 Then t = 1
If t > 0 And t < 12 Then
lhandx = 20: lhandy = 30
'Left Arm
For wid2 = .1 To 3 Step .1
Line (player.x + camera.x - 10 - wid2, player.y + camera.y + 10)-(player.x + camera.x - 20 - wid2, player.y + camera.y + 30), _RGB32(255, 166, 127)
Next wid2
'Right Arm
For wid1 = .1 To 3 Step .1
Line (player.x + camera.x + 10 + wid1, player.y + camera.y + 10)-(player.x + camera.x + 20 + wid1, player.y + camera.y + 30), _RGB32(255, 166, 127)
Next wid1
'Left leg
For wid2 = .1 To 3 Step .1
Line (player.x + camera.x - 10 + wid2, player.y + camera.y + 40)-(player.x + camera.x - 10 + wid2, player.y + camera.y + 60), _RGB32(255, 166, 127)
Next wid2
'Right leg
For wid1 = .1 To 3 Step .1
Line (player.x + camera.x + 10 - wid1, player.y + camera.y + 40)-(player.x + camera.x + 10 - wid1, player.y + camera.y + 60), _RGB32(255, 166, 127)
Next wid1
End If
If t > 11 And t < 25 Then
lhandx = 30: lhandy = 30
'Left Arm
For wid2 = .1 To 3 Step .1
Line (player.x + camera.x - 10 - wid2, player.y + camera.y + 10)-(player.x + camera.x - 30 - wid2, player.y + camera.y + 30), _RGB32(255, 166, 127)
Next wid2
'Right Arm
For wid1 = .1 To 3 Step .1
Line (player.x + camera.x + 10 + wid1, player.y + camera.y + 10)-(player.x + camera.x + 30 + wid1, player.y + camera.y + 30), _RGB32(255, 166, 127)
Next wid1
'Left leg
For wid2 = .1 To 3 Step .1
Line (player.x + camera.x - 10 + wid2, player.y + camera.y + 40)-(player.x + camera.x - 15 + wid2, player.y + camera.y + 60), _RGB32(255, 166, 127)
Next wid2
'Right leg
For wid1 = .1 To 3 Step .1
Line (player.x + camera.x + 10 - wid1, player.y + camera.y + 40)-(player.x + camera.x + 15 - wid1, player.y + camera.y + 60), _RGB32(255, 166, 127)
Next wid1
End If
If town = 2 Then
If drag < 1 Then GoTo nex:
'Draw Dragon
If player.x > drax Then drax = drax + 1
If player.x < drax Then drax = drax - 1
If player.y > dray Then dray = dray + 1
If player.y < dray Then dray = dray - 1
If drax > 3950 Then drax = 3950
If drax < 25 Then drax = 25
If dray > 2930 Then dray = 2930
If dray < 25 Then dray = 25
'Face
For sz = .25 To 30 Step .25
Circle (drax + camera.x, dray + camera.y), sz, _RGB32(255, 0, 0)
Next sz
'Eyes
For sz = .25 To 6 Step .25
Circle (drax - 15 + camera.x, dray - 15 + camera.y), sz, _RGB32(0, 0, 0)
Next sz
For sz = .25 To 6 Step .25
Circle (drax + 15 + camera.x, dray - 15 + camera.y), sz, _RGB32(0, 0, 0)
Next sz
'Thanks to OldMoses for most of this eye-following code.
xh% = drax - 15
yh% = dray - 15
xh2% = drax + 15
yh2% = dray - 15
dx% = player.x - xh%
dy% = player.y - yh%
mag! = _Hypot(dx%, dy%)
If mag! = 0 Then
ux! = 0: uy! = 0
Else
ux! = dx% / mag! '
uy! = dy% / mag! '
End If
spx! = ux! * 5
spy! = uy! * 5
For sz = .25 To 3.5 Step .25
Circle (xh% + spx! + camera.x, yh% + spy! + camera.y), sz, _RGB32(255, 255, 255)
Next sz
For sz = .25 To 3.5 Step .25
Circle (xh2% + spx! + camera.x, yh2% + spy! + camera.y), sz, _RGB32(255, 255, 255)
Next sz
'Mouth
For sz = .25 To 10 Step .25
Circle (drax + camera.x, dray + 15 + camera.y), sz, _RGB32(255, 255, 255), , , .5
Next sz
'body
Line (drax + camera.x, dray + 30 + camera.y)-(drax + 100 + camera.x, dray + 50 + camera.y), _RGB32(255, 0, 0), BF
For a = 0 To 15
Line (drax + a + camera.x + 30, dray + a + camera.y + 15)-(drax - a + camera.x + 30, dray + a + camera.y + 15), _RGB32(255, 0, 0)
Next a
For a = 0 To 15
Line (drax + a + camera.x + 45, dray + a + camera.y + 15)-(drax - a + camera.x + 45, dray + a + camera.y + 15), _RGB32(255, 0, 0)
Next a
For a = 0 To 15
Line (drax + a + camera.x + 60, dray + a + camera.y + 15)-(drax - a + camera.x + 60, dray + a + camera.y + 15), _RGB32(255, 0, 0)
Next a
For a = 0 To 15
Line (drax + a + camera.x + 75, dray + a + camera.y + 15)-(drax - a + camera.x + 75, dray + a + camera.y + 15), _RGB32(255, 0, 0)
Next a
'Dragon Health
_PrintString (drax + camera.x + 35, dray + camera.y + 35), Str$(drag)
'Nose
For sz = .25 To 2 Step .25
Circle (drax - 3 + camera.x, dray + camera.y), sz, _RGB32(255, 255, 255)
Circle (drax + 3 + camera.x, dray + camera.y), sz, _RGB32(255, 255, 255)
Next sz
'Ears
For a = 0 To 15
Line (drax + a + camera.x - 7, dray + a + camera.y - 38)-(drax - a + camera.x - 7, dray + a + camera.y - 38), _RGB32(255, 0, 0)
Next a
For a = 0 To 15
Line (drax + a + camera.x + 7, dray + a + camera.y - 38)-(drax - a + camera.x + 7, dray + a + camera.y - 38), _RGB32(255, 0, 0)
Next a
'legs
Line (drax + camera.x, dray + 50 + camera.y)-(drax + 10 + camera.x, dray + 80 + camera.y), _RGB32(255, 0, 0), BF
Line (drax + 25 + camera.x, dray + 50 + camera.y)-(drax + 35 + camera.x, dray + 80 + camera.y), _RGB32(255, 0, 0), BF
Line (drax + 65 + camera.x, dray + 50 + camera.y)-(drax + 75 + camera.x, dray + 80 + camera.y), _RGB32(255, 0, 0), BF
Line (drax + 90 + camera.x, dray + 50 + camera.y)-(drax + 100 + camera.x, dray + 80 + camera.y), _RGB32(255, 0, 0), BF
'Tail
a = 1
For tt = 1 To 100
s = 0
a = a - .5
If a < -33 Then a = 1
For d = 0 To a Step -.125
s = s + 1
x3 = Cos(s * 3.141592 / 180) * d
y3 = Sin(s * 3.151492 / 180) * d
Circle (x3 + drax + 100 + camera.x, y3 + dray + 40 + camera.y), 2, _RGB32(255, 0, 0)
Next d
Next tt
fire = Rnd * 100
If fire > 98 Then
firex = drax
firey = dray
For flame = .5 To 20 Step .25
If drax + camera.x > player.x + camera.x Then
firex = firex - 5
End If
If drax + camera.x < player.x + camera.x Then
firex = firex + 5
End If
If dray + camera.y > player.y + camera.y Then
firey = firey - 5
End If
If dray + camera.y < player.y + camera.y Then
firey = firey + 5
End If
For sz = .25 To flame Step .25
Circle (firex + camera.x, firey + camera.y), flame, _RGB32(255, 0, 0)
Next sz
If firex + camera.x > player.x - 20 + camera.x And firex + camera.x < player.x + 20 + camera.x And firey + camera.y > player.y + camera.y - 20 And firey + camera.y < player.y + camera.y + 20 Then
health = health - 1
player.x = (player.x) + (Rnd * 20)
player.y = (player.y) + (Rnd * 20)
_Delay .02
If health < 1 Then
_AutoDisplay
For snd = 600 To 300 Step -50
Sound snd, .5
Next snd
Locate 15, 25: Print "G A M E O V E R"
Locate 18, 25: Print "Again? (Y/N)"
Do
a$ = InKey$
If a$ = "y" Or a$ = "Y" Then GoTo begin:
If a$ = "n" Or a$ = "N" Then End
Loop
End If
GoTo nex:
End If
_Display
Next flame
End If
nex:
'Check to see if you hit the monster.
If sx > drax + camera.x - 20 And sx < drax + 20 + camera.x And sy > dray - 20 + camera.y And sy < dray + 20 + camera.y Then
drag = drag - armor
If drag < 1 Then
drax = -100
dray = -100
gold = gold + (Int(Rnd * 400) + 100)
For snd = 100 To 700 Step 50
Sound snd, 1
Next snd
If drag < 1 Then
_Delay 1
town = 1
GoTo start:
End If
End If
_Delay .02
End If
End If
_Display
Loop
Sub adjustCamera
If player.x + camera.x > _Width / 2 Or player.x + camera.x < _Width / 2 Then
camera.x = _Width / 2 - player.x
End If
If camera.x > 0 Then camera.x = 0
If camera.x < -(_Width(map) - _Width) Then camera.x = -(_Width(map) - _Width)
If player.y + camera.y > _Height / 2 Or player.y + camera.y < _Height / 2 Then
camera.y = _Height / 2 - player.y
End If
If camera.y > 0 Then camera.y = 0
If camera.y < -(_Height(map) - _Height) Then camera.y = -(_Height(map) - _Height)
End Sub
Sub Clear_MB (var As Integer)
Do Until Not _MouseButton(var)
While _MouseInput: Wend
Loop
End Sub 'Clear_MB
|