Strategiapeliesimerkki *v2.5*

Oletko tehnyt jotain, mistä muut voisivat hyötyä. Postita vinkit tänne.
Post Reply
User avatar
-Z-
Devoted Member
Posts: 682
Joined: Tue Aug 28, 2007 3:33 pm
Location: In ur danmaku, grazin ur bullets

Strategiapeliesimerkki *v2.5*

Post by -Z- » Tue Dec 25, 2007 9:56 pm

Koodaan Parhaillaan strategiapeliä, ja olenkin saanut jonkinnäköisen pohjan valmiiksi. Ajattelin pistää jakoon, jos jollekulle on käyttöä. VAROITUS! Koodissa ei ole kommentin kommenttia.
  • v2.0: Ukot typeissä.

    v2.01: muutettu "movegrid.png" "tatti.bmp":ksi

    v2.5: Lehmiä ei voi enää liikuttaa päällekkäin, ja voi valita vain oisen kerrallaan

Code: Select all

Type MOVEGRID
    Field obj
End Type

Type DUDE
    Field obj
    Field sel
End Type

SCREEN 400,301
ShowMouse OFF
ClsColor cbwhite
Color cbblack
cow=LoadObject("media/cow.bmp")
ShowObject cow, OFF
greengrid = LoadObject("media/movegrid.png")
ShowObject greengrid, OFF
rotation=0

soldier.DUDE = New(DUDE)
soldier\obj = CloneObject(cow)
ScreenPositionObject soldier\obj, 15,15
soldier.DUDE = New(DUDE)
soldier\obj = CloneObject(cow)
ScreenPositionObject soldier\obj, 285,285
Repeat
    For i = 1 To 11
        Line x,0,x,300
        x+30
    Next i
    x=0
    For i = 1 To 11
        Line 0,y,300,y
        y+30
    Next i
    y=0

    For soldier.DUDE = Each DUDE

        If MouseWX()>ObjectX(soldier\obj)-15 And MouseWX()<ObjectX(soldier\obj)+15 And MouseWY()<ObjectY(soldier\obj)+15 And MouseWY()>ObjectY(soldier\obj)-15 Then          
            If MouseHit(1) Then
                For guy.DUDE = Each DUDE
                    guy\sel=0
                Next guy
                For grid.MOVEGRID = Each MOVEGRID 
                    DeleteObject grid\obj
                    Delete grid   
                Next grid
                soldier\sel=1
                For i = 1 To 4
                    mgrid.MOVEGRID = New(MOVEGRID)
                    mgrid\obj = CloneObject(greengrid)
                    CloneObjectPosition  mgrid\obj, soldier\obj
                    RotateObject mgrid\obj, rotation
                    MoveObject mgrid\obj, 30
                    rotation + 90
                    For soldier2.DUDE = Each DUDE
                        If ObjectsOverlap(soldier2\obj, mgrid\obj) Then
                            DeleteObject mgrid\obj
                            Delete mgrid
                            Exit
                        EndIf
                    Next soldier2
                Next i
            EndIf
        EndIf

    For mgrid.MOVEGRID = Each MOVEGRID
     
            If ObjectsOverlap(soldier\obj, mgrid\obj) Then 
                DeleteObject mgrid\obj
                Delete mgrid
                Exit
            EndIf

        

        If MouseWX()>ObjectX(mgrid\obj)-15 And MouseWX()<ObjectX(mgrid\obj)+15 And MouseWY()>ObjectY(mgrid\obj)-15 And MouseWY()<ObjectY(mgrid\obj)+15 And soldier\sel=1 Then
            If MouseHit(1) Then
                CloneObjectPosition soldier\obj, mgrid\obj
                For grid.MOVEGRID = Each MOVEGRID 
                    DeleteObject grid\obj
                    Delete grid   
                Next grid
                mgrid.MOVEGRID = New(MOVEGRID)
                mgrid\obj = CloneObject(greengrid)
                PositionObject mgrid\obj, 300,300
                Exit
            EndIf
        EndIf
    Next mgrid  
    Next soldier
               
    DrawGame 
    
    Color 100,100,100
    Box 301,0,100,301
    Color cbblack
    
    Text 302,2, MouseX()+":"+MouseY()
    
    Color cbred
    Dot MouseX(), MouseY()
    Dot MouseX()+1, MouseY()
    Dot MouseX()-1, MouseY()
    Dot MouseX(), MouseY()+1
    Dot MouseX(), MouseY()-1
    Color cbblack
    
    DrawScreen
Until EscapeKey()
Last edited by -Z- on Sat Dec 29, 2007 10:51 pm, edited 4 times in total.
"Fallout 3 (#10) marked a shift in the industry, a move that saw the western RPG begin to surpass its Japanese counterparts." -IGN top 100 RPGs of all time

User avatar
-Z-
Devoted Member
Posts: 682
Joined: Tue Aug 28, 2007 3:33 pm
Location: In ur danmaku, grazin ur bullets

Re: Strategiapeliesimerkki

Post by -Z- » Sat Dec 29, 2007 2:47 pm

Päivitys: Nyt on ukot tyypeissä (= Tästä voi jollekulle jopa olla hyötyä).
"Fallout 3 (#10) marked a shift in the industry, a move that saw the western RPG begin to surpass its Japanese counterparts." -IGN top 100 RPGs of all time

Connect
Newcomer
Posts: 17
Joined: Sun Dec 09, 2007 4:09 pm
Location: Konnevesi

Re: Strategiapeliesimerkki *v2.0*

Post by Connect » Sat Dec 29, 2007 3:42 pm

"Can't load object: 'media/movegrid.png'.????jos vaikka pistäisit tänne movegrid.png:n?

Pabnih
Newcomer
Posts: 34
Joined: Thu Sep 20, 2007 3:15 pm
Location: Hirvas

Re: Strategiapeliesimerkki *v2.01*

Post by Pabnih » Sat Dec 29, 2007 6:58 pm

Tällä systeemillähän voisi vääntää jonkinlaisen kaksinpeli shakin harjoittelutyöksi :) Kiitos.

Post Reply