muokkasin hiukan (siis käyttäjä ystävällisemmäksi) ja lisäsin yhden tärkeän ominaisuuden jos ei haluukkaan spriteä voi painaa hiiren oikeaa nappia (2) niin se aborttaa meinaa tuli 160 spriteä kun kentässä sitten oli vain ~60 kun heitin ne aina ulko puolelle karttaa
Code: Select all
SCREEN 800, 600
Dim scenery(500)
Dim scenerynames(500) As String
Dim rain(500, 5) As Float
Type SCENERYOBJECTS
Field sceX As Float
Field sceY As Float
Field layer As integer
Field name As String
End Type
Type WAYPOINTS
Field Xcoord
Field Ycoord
Field speedX As Float
Field speedY As Float
Field speedX2 As Float
Field speedY2 As Float
Field newX
Field newY
Field newX2
Field newY2
End Type
Global backlayer
rainAmount = 500
raintype = 1
entityso=False
backvisible = True
hitvisible = True
overvisible = True
circ = MakeImage(5,5)
DrawToImage circ
Color cbdarkred
Circle 0,0, 5
Color cbred
Circle 1,1, 3
DrawToScreen
Color cbwhite
For i = 0 To RainAmount
Rain(i,0) = Rand(1, 800)
rain(i,01) = Rand(-600, 0)
Next i
font=LoadFont("arial")
AddText "Ladataan maastonkappaleita..."
DrawScreen
ChDir "SCENERY"
StartSearch
Repeat
file$ = FindFile()
If file$ = "" Then Exit
AddText "file: " +file
DrawScreen
If IsDirectory(file) = False And file <> "Thumbs.db" Then
scenery(maastonkappaleet) = LoadImage(file$)
MaskImage scenery(maastonkappaleet), 0, 255, 0
scenerynames(maastonkappaleet) = file$
maastonkappaleet + 1
EndIf
Forever
EndSearch
ChDir ".."
ChDir "MAPS"
Repeat
ClearText
LoadedMap$ = Input ("Karttatiedoston polku (jos tiedostoa ei ole olemassa, se luodaan): ")
If KeyHit(cbkeyreturn) Then
If FileExists(loadedmap) Then
kartanpolku$ = Loadedmap
Gosub mapload
CloseInput
Goto EDITOR
Else
kartanpolku$ = Loadedmap
CloseInput
Goto NEWLEVEL
EndIf
EndIf
DrawScreen
Forever
NEWLEVEL:
ChDir "MAPS"
Repeat
texture$ = Input ("Tekstuuritiedoston polku: ")
DrawScreen
Until KeyHit(cbkeyreturn)
MapTexture = LoadImage(texture)
CloseInput
Repeat
shape$ = Input ("Karttatiedoston polku: ")
DrawScreen
Until KeyHit(cbkeyreturn)
MapShape = LoadImage(shape)
CloseInput
AddText "Luodaan karttaa..."
DrawScreen
MaskImage MapShape, 0, 255, 0
ResizeImage MapShape, ImageWidth(MapShape) * 2, ImageHeight(MapShape) * 2
Xkerroin = RoundUp(ImageWidth(mapshape) / ImageWidth(MapTexture))
Ykerroin = RoundUp(ImageHeight(mapshape) / ImageHeight(MapTexture))
HitLayer = MakeImage (ImageWidth(MapShape), ImageHeight(MapShape))
DrawToImage HitLayer
For x = 0 To Xkerroin
For y = 0 To Ykerroin
DrawImage MapTexture, ImageWidth(Maptexture) * x, ImageHeight(Maptexture) * y
Next y
Next x
DrawImage MapShape, 0, 0
BackLayer = MakeImage (ImageWidth(MapShape), ImageHeight(MapShape))
OverLayer = MakeImage (ImageWidth(MapShape), ImageHeight(MapShape))
DrawToScreen
EDITOR:
showpoints = True
Repeat
Color cbwhite
//ClearText //reset text
Text 0,0, "FPS: " +FPS()
Text 0,14, "Valitse tasojen näkyvyys A-, S- ja D-näppäimillä."
Text 0,28, "Luo waypointeja klikkaamalla hiiren oikeaa painiketta."
Text 0,42, "Valitse kentän taustaväri painamalla control-näppäintä."
Text 0,56, "Valitse sateen tyyppi 1, 2 tai 3 -näppäintä."
Text 0,70, "Paina r avataksesi sprite palkin."
If entityso=True Then
Text 0, 196,"valitse sprite klikkaamalla (vasen nappi(1))"
Text 0, 210,"sijoita sprite haluamaasi paikkaan ja klikkaa hiiren vasenta nappia (1)"
Text 0,224,"jos muutat mielesi ja et haluakkaan valittua spriteä paina hiiren oikeaa nappia (2)"
EndIf
If KeyHit(cbkeyr) Then entityso=Not entityso
If KeyHit(30) Then backvisible=Not backvisible
If backvisible = True Then DrawImage backlayer, WorldToScreenX(0), WorldToScreenY(0)
If KeyHit(31) Then hitvisible=Not hitvisible
If hitvisible = True Then DrawImage hitlayer, WorldToScreenX(0), WorldToScreenY(0)
If KeyHit(32) Then overvisible=Not overvisible
If overvisible = True Then DrawImage overlayer, WorldToScreenX(0), WorldToScreenY(0)
If backvisible=1 Then
Text 0,84,"Taustakerros näkyy"
Else
Text 0,84,"Taustakerros ei näy"
EndIf
If hitvisible=1 Then
text 0,98,"Törmäyskerros näkyy"
Else
Text 0,98,"Törmäyskerros ei näy"
EndIf
If overvisible=1 Then
Text 0,112,"Päälliskerros näkyy"
Else
Text 0,112,"Päälliskerros ei näy"
EndIf
If KeyHit(16) Then EditedLayer = 1
If KeyHit(17) Then editedlayer = 2
If KeyHit(18) Then editedlayer = 3
Select editedlayer
Case 0
Text 0,140,"Muokattava kerros: "
Case 1
Text 0,140,"Muokattava kerros: back-kerros"
Case 2
Text 0,140,"Muokattava kerros: hit-kerros"
Case 3
Text 0,140,"Muokattava kerros: over-kerros"
EndSelect
TranslateCamera RightKey() * 5 - LeftKey() * 5, UpKey() * 5 - DownKey() * 5
If KeyHit(59) Then Gosub SaveMap
If KeyHit(157) Then
Repeat
ClearText
AddText "colorsetup: " +colorsetup
AddText "RED 1: " +r1
AddText "GREEN 1: " + g1
AddText "BLUE 1: " +b1
AddText "RED 2: " +r2
AddText "GREEN 2: " + g2
AddText "BLUE 2: " +b2
Select colorsetup
Case 0
If LeftKey() Then R1 - 1
If RightKey() Then R1 + 1
Case 1
If LeftKey() Then G1 - 1
If RightKey() Then G1 + 1
Case 2
If LeftKey() Then B1 - 1
If RightKey() Then B1 + 1
Case 3
If LeftKey() Then R2 - 1
If RightKey() Then R2 + 1
Case 4
If LeftKey() Then G2 - 1
If RightKey() Then G2 + 1
Case 5
If LeftKey() Then B2 - 1
If RightKey() Then B2 + 1
If KeyHit(208) Then Exit
End Select
If KeyHit(200) Then colorsetup - 1
If KeyHit(208) Then colorsetup + 1
DrawScreen
Forever
MakeGradient(ImageWidth(backlayer) * 1.5, ImageHeight(backlayer) * 1.5, r1, g1, b1, r2, g2, b2)
EndIf
Select RainType
Case 1
For i = 0 To RainAmount
If Rain(i,2) = 0 Then Rain(i,2) = Rnd(4,5)
If rain(i,3) = 0 Then rain(i,3) = Rnd(2,4)
Rain(i,0) = Rain(i,0) - rain(i, 2)
Rain(i,1) = Rain(i,1) + rain(i, 3)
Dot rain(i,0), rain(i,1)
If Rain(i,1) > 800 Or rain(i,0) < 0 Then Rain(i,1) = 0 : Rain(i,0) = Rand(2,1800)
Next i
Case 2
For i = 0 To RainAmount
rain(i,2) = 0
If rain(i,3) = 0 Then rain(i,3) = Rnd(2,4)
Rain(i,0) = Rain(i,0) - rain(i, 2)
Rain(i,1) = Rain(i,1) + rain(i, 3)
Dot rain(i,0), rain(i,1)
If Rain(i,1) > 800 Then Rain(i,1) = 0 : Rain(i,0) = Rand(0,800)
Next i
End Select
If KeyHit(cbkey1) Then raintype = 1
If KeyHit(cbkey2) Then raintype = 2
If KeyHit(cbkey3) Then raintype = 3
If KeyHit(cbkeyZ) Then
If showpoints = False Then showpoints = True Else showpoints = False
EndIf
Text 0,164,"PlacingWaypoint: " +placingwaypoint
If MouseHit(2) And placingwaypoint = False And placingScenery=False Then
way.WAYPOINTS = New(WAYPOINTS)
waypointAmount + 1
way\Xcoord = MouseWX()
way\Ycoord = MouseWY()
PlacingWaypoint = True
EndIf
If PlacingWaypoint = True Then
AddText "Klikkaamalla hiiren vasemmalla painikkeella saat valittua mihin suuntaan"
AddText "botti lähtee tullessaan waypointille."
AddText "Voit luoda toisen vaihtoehtoisen suunnan klikkaamalla hiiren keskimmäisellä"
AddText "painikkeella. Tullessaan waypointille, johon on tallennettu kaksi suuntaa, "
AddText "botti lähtee sattumanvaraisesti toiseen niistä."
angle = GetAngle(WorldToScreenX(way\Xcoord), WorldToScreenY(way\Ycoord), MouseX(), MouseY())
dist = Distance(WorldToScreenX(way\Xcoord), WorldToScreenY(way\Ycoord), MouseX(), MouseY())
Line WorldToScreenX(way\Xcoord), WorldToScreenY(way\Ycoord), MouseX(), MouseY()
If way\speedX2 <> 0 Then Line WorldToScreenX(way\Xcoord), WorldToScreenY(way\Ycoord), WorldToScreenX(way\newX2), WorldToScreenY(way\newY2)
If MouseHit (1) Then
If Dist > 5 Then way\speedX = Cos(angle) : way\speedy = Sin(angle)
way\newX = MouseWX()
way\newY = MouseWY()
placingWaypoint = False
EndIf
If MouseHit(3) Then
If Dist > 5 Then way\speedX2 = Cos(angle) : way\speedY2 = Sin(angle)
way\newX2 = MouseWX()
way\newY2 = MouseWY()
EndIf
ElseIf showpoints = True
For way.WAYPOINTS = Each WAYPOINTS
DrawImage circ, WorldToScreenX(way\Xcoord) - 3, WorldToScreenY(way\Ycoord) - 3
Line WorldToScreenX(way\Xcoord), WorldToScreenY(way\Ycoord), WorldToScreenX(way\newX), WorldToScreenY(way\newY)
If way\speedX2 <> 0 Then Line WorldToScreenX(way\Xcoord), WorldToScreenY(way\Ycoord), WorldToScreenX(way\newX2), WorldToScreenY(way\newY2)
Next way
EndIf
If placingScenery = ON Then
DrawImage scenery(whatscenery), MouseX(), MouseY()
If MouseHit(1) Then
If Editedlayer = 1 Then
DrawToImage BackLayer
ElseIf EditedLayer = 2
DrawToImage HitLayer
ElseIf EditedLayer = 3
DrawToImage OverLayer
EndIf
DrawImage scenery(whatscenery), MouseWX(), -MouseWY()
DrawToScreen
sce.SCENERYOBJECTS = New(SCENERYOBJECTS)
sce\sceX = MouseWX()
sce\sceY = -MouseWY()
sce\layer = editedlayer
sce\name = scenerynames(whatscenery)
sceneryamount + 1
PlacingScenery = OFF
EndIf
If MouseHit(2) Then
PlacingScenery = OFF
EndIf
EndIf
If entityso=1 Then //entiry select open=1
Color cbsilver
Box 640,0,300,800
SetFont font
For i = 0 To maastonkappaleet
Color cbblack
Text 650, i *11, scenerynames(i)
If MouseX() > 650 Then
If MouseY() > i * 11 And MouseY() < 11 * i + 11 Then
Box 650-1, i * 11, 150, 11+1, 0
If MouseHit(1) And scenery(i) <> 0 Then
PlacingScenery = ON
WhatScenery = i
EndIf
EndIf
EndIf
Next i
EndIf
DrawScreen
Forever
'******************************************************************************************
SAVEMAP:
ChDir "MAPS"
m = OpenToWrite (kartanpolku)
WriteLine m, shape
WriteLine m, texture
WriteLine m, raintype
WriteLine m, R1
WriteLine m, G1
WriteLine m, B1
WriteLine m, R2
WriteLine m, G2
WriteLine m, B2
WriteLine m, "************************ MAASTONKAPPALEET: ***************************"
WriteLine m, sceneryamount
For sce.SCENERYOBJECTS = Each SCENERYOBJECTS
WriteLine m, sce\name
WriteLine m, sce\sceX
WriteLine m, sce\sceY
WriteLine m, sce\layer
Next sce
WriteLine m, "***************************** WAYPOINTIT ****************************** "
WriteLine m, waypointamount
For way.WAYPOINTS = Each WAYPOINTS
WriteLine m, way\Xcoord
WriteLine m, way\Ycoord
WriteLine m, way\speedX
WriteLine m, way\speedY
WriteLine m, way\speedX2
WriteLine m, way\speedY2
Next way
CloseFile m
Return
ChDir ".."
MAPLOAD:
m = OpenToRead (kartanpolku)
shape$ = ReadLine (m)
texture$ = ReadLine (m)
raintype = ReadLine (m)
R1 = ReadLine (m)
G1 = ReadLine(m)
B1 = ReadLine(m)
R2 = ReadLine(m)
G2 = ReadLine(m)
B2 = ReadLine(m)
empty = ReadLine(m)
sceneryamount = ReadLine (m)
For i = 1 To sceneryamount
sce.SCENERYOBJECTS = New(SCENERYOBJECTS)
sce\name = ReadLine (m)
sce\sceX = ReadLine (m)
sce\sceY = ReadLine (m)
sce\layer = ReadLine (m)
Next i
empty = ReadLine(m)
waypointamount = ReadLine (m)
For i = 1 To waypointamount
way.WAYPOINTS = New(WAYPOINTS)
way\Xcoord = ReadLine (m)
way\Ycoord = ReadLine (m)
way\speedX = ReadLine (m)
way\speedY = ReadLine (m)
way\speedX2 = ReadLine (m)
way\speedY2 = ReadLine (m)
Next i
CloseFile m
ChDir "MAPS"
'luodaan layerit
MapTexture = LoadImage(texture)
MapShape = LoadImage(shape)
MaskImage MapShape, 0, 255, 0
ResizeImage MapShape, ImageWidth(MapShape) * 2, ImageHeight(MapShape) * 2
Xkerroin = RoundUp(ImageWidth(mapshape) / ImageWidth(MapTexture))
Ykerroin = RoundUp(ImageHeight(mapshape) / ImageHeight(MapTexture))
HitLayer = MakeImage (ImageWidth(MapShape), ImageHeight(MapShape))
DrawToImage HitLayer
For x = 0 To Xkerroin
For y = 0 To Ykerroin
DrawImage MapTexture, ImageWidth(Maptexture) * x, ImageHeight(Maptexture) * y
Next y
Next x
DrawImage MapShape, 0, 0
DrawToScreen
MapX = ImageWidth(MapShape)
MapY = ImageHeight(MapShape)
BackLayer = MakeImage (Mapx, MapY)
OverLayer = MakeImage (ImageWidth(MapShape), ImageHeight(MapShape))
Color cbwhite
'piirretään maasto
For sce.SCENERYOBJECTS = Each SCENERYOBJECTS
If sce\layer = 1 Then
DrawToImage BackLayer
ElseIf sce\layer = 2
DrawToImage HitLayer
ElseIf sce\layer = 3
DrawToImage OverLayer
EndIf
For i = 0 To maastonkappaleet
If scenerynames(i) = sce\name And sce\sceX < MapX And sce\sceX < MapY Then
DrawImage scenery(i), sce\sceX, sce\sceY
EndIf
Next i
Next sce
DrawToScreen
ChDir ".."
Return
'******************************************************************************************
Function ScreenToWorldX(sc)
wc = CameraX() - ScreenWidth() / 2 + sc
Return wc
End Function
Function ScreenToWorldY(sc)
wc = CameraY() + ScreenHeight() / 2 - sc
Return wc
End Function
Function WorldToScreenX(wc)
sc = -CameraX() + ScreenWidth() / 2 + wc
Return sc
End Function
Function WorldToScreenY(wc)
sc = CameraY() + ScreenHeight() / 2 - wc
Return sc
End Function
Function MakeGradient(width, height, R1#, G1#, B1#, R2#, G2#, B2#)
Rdifference# = (Max(R1, R2) - Min(R1,R2)) / height
Gdifference# = (Max(G1, G2) - Min(G1,G2)) / height
Bdifference# = (Max(B1, B2) - Min(B1,B2)) / height
DrawToImage BackLayer
For i = 1 To height
Color R1 + Rdifference *i, G1 + Gdifference *i, B1 + Bdifference * i
Line 0, i, width, i
Next i
DrawToScreen
End Function
EDIT:pistin prewiev:in spriteille
Code: Select all
SCREEN 800, 600
Dim scenery(500)
Dim scenerynames(500) As String
Dim rain(500, 5) As Float
Type SCENERYOBJECTS
Field sceX As Float
Field sceY As Float
Field layer As integer
Field name As String
End Type
Type WAYPOINTS
Field Xcoord
Field Ycoord
Field speedX As Float
Field speedY As Float
Field speedX2 As Float
Field speedY2 As Float
Field newX
Field newY
Field newX2
Field newY2
End Type
Global backlayer
rainAmount = 500
raintype = 1
entityso=False
backvisible = True
hitvisible = True
overvisible = True
circ = MakeImage(5,5)
DrawToImage circ
Color cbdarkred
Circle 0,0, 5
Color cbred
Circle 1,1, 3
DrawToScreen
Color cbwhite
For i = 0 To RainAmount
Rain(i,0) = Rand(1, 800)
rain(i,01) = Rand(-600, 0)
Next i
font=LoadFont("arial")
AddText "Ladataan maastonkappaleita..."
DrawScreen
ChDir "SCENERY"
StartSearch
Repeat
file$ = FindFile()
If file$ = "" Then Exit
AddText "file: " +file
DrawScreen
If IsDirectory(file) = False And file <> "Thumbs.db" Then
scenery(maastonkappaleet) = LoadImage(file$)
MaskImage scenery(maastonkappaleet), 0, 255, 0
scenerynames(maastonkappaleet) = file$
maastonkappaleet + 1
EndIf
Forever
EndSearch
ChDir ".."
ChDir "MAPS"
Repeat
ClearText
LoadedMap$ = Input ("Karttatiedoston polku (jos tiedostoa ei ole olemassa, se luodaan): ")
If KeyHit(cbkeyreturn) Then
If FileExists(loadedmap) Then
kartanpolku$ = Loadedmap
Gosub mapload
CloseInput
Goto EDITOR
Else
kartanpolku$ = Loadedmap
CloseInput
Goto NEWLEVEL
EndIf
EndIf
DrawScreen
Forever
NEWLEVEL:
ChDir "MAPS"
Repeat
texture$ = Input ("Tekstuuritiedoston polku: ")
DrawScreen
Until KeyHit(cbkeyreturn)
MapTexture = LoadImage(texture)
CloseInput
Repeat
shape$ = Input ("Karttatiedoston polku: ")
DrawScreen
Until KeyHit(cbkeyreturn)
MapShape = LoadImage(shape)
CloseInput
AddText "Luodaan karttaa..."
DrawScreen
MaskImage MapShape, 0, 255, 0
ResizeImage MapShape, ImageWidth(MapShape) * 2, ImageHeight(MapShape) * 2
Xkerroin = RoundUp(ImageWidth(mapshape) / ImageWidth(MapTexture))
Ykerroin = RoundUp(ImageHeight(mapshape) / ImageHeight(MapTexture))
HitLayer = MakeImage (ImageWidth(MapShape), ImageHeight(MapShape))
DrawToImage HitLayer
For x = 0 To Xkerroin
For y = 0 To Ykerroin
DrawImage MapTexture, ImageWidth(Maptexture) * x, ImageHeight(Maptexture) * y
Next y
Next x
DrawImage MapShape, 0, 0
BackLayer = MakeImage (ImageWidth(MapShape), ImageHeight(MapShape))
OverLayer = MakeImage (ImageWidth(MapShape), ImageHeight(MapShape))
DrawToScreen
EDITOR:
showpoints = True
Repeat
Color cbwhite
//ClearText //reset text
Text 0,0, "FPS: " +FPS()
Text 0,14, "Valitse tasojen näkyvyys A-, S- ja D-näppäimillä."
Text 0,28, "Luo waypointeja klikkaamalla hiiren oikeaa painiketta."
Text 0,42, "Valitse kentän taustaväri painamalla control-näppäintä."
Text 0,56, "Valitse sateen tyyppi 1, 2 tai 3 -näppäintä."
Text 0,70, "Paina r avataksesi sprite palkin."
If entityso=True Then
Text 0, 196,"valitse sprite klikkaamalla (vasen nappi(1))"
Text 0, 210,"sijoita sprite haluamaasi paikkaan ja klikkaa hiiren vasenta nappia (1)"
Text 0,224,"jos muutat mielesi ja et haluakkaan valittua spriteä paina hiiren oikeaa nappia (2)"
EndIf
If KeyHit(cbkeyr) Then entityso=Not entityso
If KeyHit(30) Then backvisible=Not backvisible
If backvisible = True Then DrawImage backlayer, WorldToScreenX(0), WorldToScreenY(0)
If KeyHit(31) Then hitvisible=Not hitvisible
If hitvisible = True Then DrawImage hitlayer, WorldToScreenX(0), WorldToScreenY(0)
If KeyHit(32) Then overvisible=Not overvisible
If overvisible = True Then DrawImage overlayer, WorldToScreenX(0), WorldToScreenY(0)
If backvisible=1 Then
Text 0,84,"Taustakerros näkyy"
Else
Text 0,84,"Taustakerros ei näy"
EndIf
If hitvisible=1 Then
text 0,98,"Törmäyskerros näkyy"
Else
Text 0,98,"Törmäyskerros ei näy"
EndIf
If overvisible=1 Then
Text 0,112,"Päälliskerros näkyy"
Else
Text 0,112,"Päälliskerros ei näy"
EndIf
If KeyHit(16) Then EditedLayer = 1
If KeyHit(17) Then editedlayer = 2
If KeyHit(18) Then editedlayer = 3
Select editedlayer
Case 0
Text 0,140,"Muokattava kerros: "
Case 1
Text 0,140,"Muokattava kerros: back-kerros"
Case 2
Text 0,140,"Muokattava kerros: hit-kerros"
Case 3
Text 0,140,"Muokattava kerros: over-kerros"
EndSelect
TranslateCamera RightKey() * 5 - LeftKey() * 5, UpKey() * 5 - DownKey() * 5
If KeyHit(59) Then Gosub SaveMap
If KeyHit(157) Then
Repeat
ClearText
AddText "colorsetup: " +colorsetup
AddText "RED 1: " +r1
AddText "GREEN 1: " + g1
AddText "BLUE 1: " +b1
AddText "RED 2: " +r2
AddText "GREEN 2: " + g2
AddText "BLUE 2: " +b2
Select colorsetup
Case 0
If LeftKey() Then R1 - 1
If RightKey() Then R1 + 1
Case 1
If LeftKey() Then G1 - 1
If RightKey() Then G1 + 1
Case 2
If LeftKey() Then B1 - 1
If RightKey() Then B1 + 1
Case 3
If LeftKey() Then R2 - 1
If RightKey() Then R2 + 1
Case 4
If LeftKey() Then G2 - 1
If RightKey() Then G2 + 1
Case 5
If LeftKey() Then B2 - 1
If RightKey() Then B2 + 1
If KeyHit(208) Then Exit
End Select
If KeyHit(200) Then colorsetup - 1
If KeyHit(208) Then colorsetup + 1
DrawScreen
Forever
MakeGradient(ImageWidth(backlayer) * 1.5, ImageHeight(backlayer) * 1.5, r1, g1, b1, r2, g2, b2)
EndIf
Select RainType
Case 1
For i = 0 To RainAmount
If Rain(i,2) = 0 Then Rain(i,2) = Rnd(4,5)
If rain(i,3) = 0 Then rain(i,3) = Rnd(2,4)
Rain(i,0) = Rain(i,0) - rain(i, 2)
Rain(i,1) = Rain(i,1) + rain(i, 3)
Dot rain(i,0), rain(i,1)
If Rain(i,1) > 800 Or rain(i,0) < 0 Then Rain(i,1) = 0 : Rain(i,0) = Rand(2,1800)
Next i
Case 2
For i = 0 To RainAmount
rain(i,2) = 0
If rain(i,3) = 0 Then rain(i,3) = Rnd(2,4)
Rain(i,0) = Rain(i,0) - rain(i, 2)
Rain(i,1) = Rain(i,1) + rain(i, 3)
Dot rain(i,0), rain(i,1)
If Rain(i,1) > 800 Then Rain(i,1) = 0 : Rain(i,0) = Rand(0,800)
Next i
End Select
If KeyHit(cbkey1) Then raintype = 1
If KeyHit(cbkey2) Then raintype = 2
If KeyHit(cbkey3) Then raintype = 3
If KeyHit(cbkeyZ) Then
If showpoints = False Then showpoints = True Else showpoints = False
EndIf
Text 0,164,"PlacingWaypoint: " +placingwaypoint
If MouseHit(2) And placingwaypoint = False And placingScenery=False Then
way.WAYPOINTS = New(WAYPOINTS)
waypointAmount + 1
way\Xcoord = MouseWX()
way\Ycoord = MouseWY()
PlacingWaypoint = True
EndIf
If PlacingWaypoint = True Then
AddText "Klikkaamalla hiiren vasemmalla painikkeella saat valittua mihin suuntaan"
AddText "botti lähtee tullessaan waypointille."
AddText "Voit luoda toisen vaihtoehtoisen suunnan klikkaamalla hiiren keskimmäisellä"
AddText "painikkeella. Tullessaan waypointille, johon on tallennettu kaksi suuntaa, "
AddText "botti lähtee sattumanvaraisesti toiseen niistä."
angle = GetAngle(WorldToScreenX(way\Xcoord), WorldToScreenY(way\Ycoord), MouseX(), MouseY())
dist = Distance(WorldToScreenX(way\Xcoord), WorldToScreenY(way\Ycoord), MouseX(), MouseY())
Line WorldToScreenX(way\Xcoord), WorldToScreenY(way\Ycoord), MouseX(), MouseY()
If way\speedX2 <> 0 Then Line WorldToScreenX(way\Xcoord), WorldToScreenY(way\Ycoord), WorldToScreenX(way\newX2), WorldToScreenY(way\newY2)
If MouseHit (1) Then
If Dist > 5 Then way\speedX = Cos(angle) : way\speedy = Sin(angle)
way\newX = MouseWX()
way\newY = MouseWY()
placingWaypoint = False
EndIf
If MouseHit(3) Then
If Dist > 5 Then way\speedX2 = Cos(angle) : way\speedY2 = Sin(angle)
way\newX2 = MouseWX()
way\newY2 = MouseWY()
EndIf
ElseIf showpoints = True
For way.WAYPOINTS = Each WAYPOINTS
DrawImage circ, WorldToScreenX(way\Xcoord) - 3, WorldToScreenY(way\Ycoord) - 3
Line WorldToScreenX(way\Xcoord), WorldToScreenY(way\Ycoord), WorldToScreenX(way\newX), WorldToScreenY(way\newY)
If way\speedX2 <> 0 Then Line WorldToScreenX(way\Xcoord), WorldToScreenY(way\Ycoord), WorldToScreenX(way\newX2), WorldToScreenY(way\newY2)
Next way
EndIf
If placingScenery = ON Then
DrawImage scenery(whatscenery), MouseX(), MouseY()
If MouseHit(1) Then
If Editedlayer = 1 Then
DrawToImage BackLayer
ElseIf EditedLayer = 2
DrawToImage HitLayer
ElseIf EditedLayer = 3
DrawToImage OverLayer
EndIf
DrawImage scenery(whatscenery), MouseWX(), -MouseWY()
DrawToScreen
sce.SCENERYOBJECTS = New(SCENERYOBJECTS)
sce\sceX = MouseWX()
sce\sceY = -MouseWY()
sce\layer = editedlayer
sce\name = scenerynames(whatscenery)
sceneryamount + 1
PlacingScenery = OFF
EndIf
If MouseHit(2) Then
PlacingScenery = OFF
EndIf
EndIf
If entityso=1 Then //entiry select open=1
Color cbsilver
Box 640,0,300,600
SetFont font
For i = 0 To maastonkappaleet
Color cbblack
Text 650, i *11, scenerynames(i)
If MouseX() > 650 Then
If MouseY() > i * 11 And MouseY() < 11 * i + 11 Then
Box 650-1, i * 11, 150, 11+1, 0
tScenery=i //minkä päällä hiiri on (määrää thumb imagen)
If MouseHit(1) And scenery(i) <> 0 Then
PlacingScenery = ON
WhatScenery = i
EndIf
EndIf
EndIf
Next i
//thumb image
Color cbsilver
Box 520,500,100,100,1
If tScenery<maastonkappaleet Then
thumb=CloneImage (scenery(tScenery))
EndIf
ResizeImage thumb,98,98
DrawImage thumb, 521,501
EndIf
DrawScreen
Forever
'******************************************************************************************
SAVEMAP:
ChDir "MAPS"
m = OpenToWrite (kartanpolku)
WriteLine m, shape
WriteLine m, texture
WriteLine m, raintype
WriteLine m, R1
WriteLine m, G1
WriteLine m, B1
WriteLine m, R2
WriteLine m, G2
WriteLine m, B2
WriteLine m, "************************ MAASTONKAPPALEET: ***************************"
WriteLine m, sceneryamount
For sce.SCENERYOBJECTS = Each SCENERYOBJECTS
WriteLine m, sce\name
WriteLine m, sce\sceX
WriteLine m, sce\sceY
WriteLine m, sce\layer
Next sce
WriteLine m, "***************************** WAYPOINTIT ****************************** "
WriteLine m, waypointamount
For way.WAYPOINTS = Each WAYPOINTS
WriteLine m, way\Xcoord
WriteLine m, way\Ycoord
WriteLine m, way\speedX
WriteLine m, way\speedY
WriteLine m, way\speedX2
WriteLine m, way\speedY2
Next way
CloseFile m
Return
ChDir ".."
MAPLOAD:
m = OpenToRead (kartanpolku)
shape$ = ReadLine (m)
texture$ = ReadLine (m)
raintype = ReadLine (m)
R1 = ReadLine (m)
G1 = ReadLine(m)
B1 = ReadLine(m)
R2 = ReadLine(m)
G2 = ReadLine(m)
B2 = ReadLine(m)
empty = ReadLine(m)
sceneryamount = ReadLine (m)
For i = 1 To sceneryamount
sce.SCENERYOBJECTS = New(SCENERYOBJECTS)
sce\name = ReadLine (m)
sce\sceX = ReadLine (m)
sce\sceY = ReadLine (m)
sce\layer = ReadLine (m)
Next i
empty = ReadLine(m)
waypointamount = ReadLine (m)
For i = 1 To waypointamount
way.WAYPOINTS = New(WAYPOINTS)
way\Xcoord = ReadLine (m)
way\Ycoord = ReadLine (m)
way\speedX = ReadLine (m)
way\speedY = ReadLine (m)
way\speedX2 = ReadLine (m)
way\speedY2 = ReadLine (m)
Next i
CloseFile m
ChDir "MAPS"
'luodaan layerit
MapTexture = LoadImage(texture)
MapShape = LoadImage(shape)
MaskImage MapShape, 0, 255, 0
ResizeImage MapShape, ImageWidth(MapShape) * 2, ImageHeight(MapShape) * 2
Xkerroin = RoundUp(ImageWidth(mapshape) / ImageWidth(MapTexture))
Ykerroin = RoundUp(ImageHeight(mapshape) / ImageHeight(MapTexture))
HitLayer = MakeImage (ImageWidth(MapShape), ImageHeight(MapShape))
DrawToImage HitLayer
For x = 0 To Xkerroin
For y = 0 To Ykerroin
DrawImage MapTexture, ImageWidth(Maptexture) * x, ImageHeight(Maptexture) * y
Next y
Next x
DrawImage MapShape, 0, 0
DrawToScreen
MapX = ImageWidth(MapShape)
MapY = ImageHeight(MapShape)
BackLayer = MakeImage (Mapx, MapY)
OverLayer = MakeImage (ImageWidth(MapShape), ImageHeight(MapShape))
Color cbwhite
'piirretään maasto
For sce.SCENERYOBJECTS = Each SCENERYOBJECTS
If sce\layer = 1 Then
DrawToImage BackLayer
ElseIf sce\layer = 2
DrawToImage HitLayer
ElseIf sce\layer = 3
DrawToImage OverLayer
EndIf
For i = 0 To maastonkappaleet
If scenerynames(i) = sce\name And sce\sceX < MapX And sce\sceX < MapY Then
DrawImage scenery(i), sce\sceX, sce\sceY
EndIf
Next i
Next sce
DrawToScreen
ChDir ".."
Return
'******************************************************************************************
Function ScreenToWorldX(sc)
wc = CameraX() - ScreenWidth() / 2 + sc
Return wc
End Function
Function ScreenToWorldY(sc)
wc = CameraY() + ScreenHeight() / 2 - sc
Return wc
End Function
Function WorldToScreenX(wc)
sc = -CameraX() + ScreenWidth() / 2 + wc
Return sc
End Function
Function WorldToScreenY(wc)
sc = CameraY() + ScreenHeight() / 2 - wc
Return sc
End Function
Function MakeGradient(width, height, R1#, G1#, B1#, R2#, G2#, B2#)
Rdifference# = (Max(R1, R2) - Min(R1,R2)) / height
Gdifference# = (Max(G1, G2) - Min(G1,G2)) / height
Bdifference# = (Max(B1, B2) - Min(B1,B2)) / height
DrawToImage BackLayer
For i = 1 To height
Color R1 + Rdifference *i, G1 + Gdifference *i, B1 + Bdifference * i
Line 0, i, width, i
Next i
DrawToScreen
End Function
[/edit]