Tallennuksessa vikaa

Voit pyytää apua ohjelmointiongelmiin täältä.
Post Reply
User avatar
MaGetzUb
Guru
Posts: 1715
Joined: Sun Sep 09, 2007 12:35 pm
Location: Alavus

Tallennuksessa vikaa

Post by MaGetzUb » Thu Oct 02, 2008 10:10 pm

Tein tällaaset 2 funktiota, joilla voi tallentaa & ladata mapissa olevat tiedot. Kun testasin tuo lataus funktio pisteli minne sattuu Health Pack:eja ja Bullet Packeja, joten voisiko joku tutkia nuo funktiot läpi ja kertoa, löytyykö sieltä virheitä. Kiitos jo etukäteen. :D

Code: Select all

Function SaveMap(mapfile$,tekiä$)
mapf = OpenToWrite(mapfile$+".PCW") 
WriteLine mapf,"..::PolyCave::.."
WriteLine mapf,"----Mapfile version 0.5----"
WriteLine mapf,"Map by: "+tekiä$
WriteLine mapf,"-----------------------------------"
WriteLine mapf,Ship_X
WriteLine mapf,Ship_Y
WriteLine mapf,Ship_Angle
WriteLine mapf,"---------PolyGons----------"
WriteLine mapf,PolyGonCount()
For PolyGon.PolyGons = Each PolyGons
WriteLine mapf,PolyGon\PolyGon_ID
WriteLine mapf,PolyGon\PolyGon_X1
WriteLine mapf,PolyGon\PolyGon_Y1
WriteLine mapf,PolyGon\PolyGon_X2
WriteLine mapf,PolyGon\PolyGon_Y2
Next PolyGon
WriteLine mapf,"---Healthpack Places---"
WriteLine mapf,HealthPackCount()
For   HP.HealthPacks = Each HealthPacks
WriteLine mapf,HP\HealthPackX
WriteLine mapf,HP\HealthPackY
Next Hp
WriteLine mapf,"---BulletPack Places---"
WriteLine mapf,BulletPackCount()
For  BP.BulletPacks = Each BulletPacks
WriteLine mapf,BP\BulletPackX
WriteLine mapf,BP\BulletPackY
Next BP
WriteLine mapf,"-----------Enemies----------"
WriteLine mapf, EnemyCount()
For Enemy.Enemies = Each Enemies
WriteLine mapf,Enemy\EnemyX
WriteLine mapf,Enemy\EnemyY
WriteLine mapf,Enemy\EnemyAngle
Next Enemy
WriteLine mapf,"---------WayPoints--------"
WriteLine mapf,WayPointCount()
For WP.WayPoints = Each WayPoints
WriteLine mapf,Wp\WayPoint_X
WriteLine mapf,Wp\WayPoint_Y
WriteLine mapf,Wp\WayPoint_Ang
WriteLine mapf,Wp\WayPoint_ExtraAng  
WriteLine mapf,Wp\WayPoint_Ang2
Next WP
CloseFile mapf
EndFunction 

Function OpenMapFile(mapfile$)
mapf = OpenToRead(mapfile$+".PCW")
emptyline = ReadLine(mapf)
emptyline = ReadLine(mapf)
emptyline = ReadLine(mapf)
emptyline = ReadLine(mapf)
Ship_X = ReadLine(mapf)
Ship_Y = ReadLine(mapf)
Ship_Angle = ReadLine(mapf)
emptyline = ReadLine(mapf)
polycount =  ReadLine(mapf)
For i = 0 To polycount
 PolyGon.PolyGons = New(PolyGons)
 PolyGon\PolyGon_ID = ReadLine(mapf)
 PolyGon\PolyGon_X1 = ReadLine(mapf)
 PolyGon\PolyGon_Y1 = ReadLine(mapf)
 PolyGon\PolyGon_X2 = ReadLine(mapf)
 PolyGon\PolyGon_Y2 = ReadLine(mapf)
Next i
emptyline = ReadLine(mapf)
hpcount = ReadLine(mapf)
For i = 0 To hpcount
HP.HealthPacks = New (HealthPacks)
HP\HealthPackX = ReadLine(mapf)
HP\HealthPackY = ReadLine(mapf)
Next i
emptyline = ReadLine(mapf)
bpcount = ReadLine(mapf)
For i = 0 To hpcount
BP.BulletPacks = New (BulletPacks)
BP\BulletPackX = ReadLine(mapf)
BP\BulletPackY = ReadLine(mapf)
Next i
emptyline = ReadLine(mapf)
vihucount = ReadLine(mapf)
For i = 0 To vihucount
Enemy.Enemies = New(Enemies)
Enemy\EnemyX = ReadLine(mapf)
Enemy\EnemyY = ReadLine(mapf)
Enemy\EnemyAngle = ReadLine(mapf)
Next i
emptyline = ReadLine(mapf)
wps = ReadLine(mapf)
For i = 1 To wps
Wp.WayPoints = New (WayPoints)
Wp\WayPoint_ID =ReadLine(mapf)
Wp\WayPoint_X =ReadLine(mapf)
Wp\WayPoint_Y =ReadLine(mapf)
Wp\WayPoint_Ang =ReadLine(mapf)
Wp\WayPoint_ExtraAng =ReadLine(mapf)
Wp\WayPoint_Ang2 =ReadLine(mapf) 
Next i
EndFunction
EDIT:

Taisin huomata ongelman..

EDIT:

Ei toiminut vieläkään kunnolla.. :(

Solar Eclipse
Meneillä olevat Projektit:
We're in a simulation, and God is trying to debug us.

cheeshelmet.jr
Member
Posts: 75
Joined: Tue Aug 28, 2007 6:59 am

Re: Tallennuksessa vikaa

Post by cheeshelmet.jr » Fri Oct 03, 2008 3:35 pm

En tiedä mutta kokeile muuttaa int() komennolla niitä missä luetaan packin sijainti tai esim suoraan kirjoitat tiedostoon numerona ja luet sen numerona.

Post Reply