|
| |
|
|
Tutti i fusi orari sono GMT
|
|
 |
Gio Ott 12, 2006 1:15 pm |
 |
Autore |
Messaggio |
Rafery

Registrato: 05/05/05 20:55 Messaggi: 37 Residenza: Sauze d'Oulx
|
| Oggetto: Terreno accidentato! Fermati. |
|
|
Secondo voi esiste una possibilita' di fermare questo eroe senza dovergli
per forza SPARARE?
Provate a eseguire il codice e ditemi qualcosa per favore.
grazie.
So che basta non mettere l'istruzione: ypos = ypos + 2
per non farlo ballare me se trovi una salita lui 'entra' nel terreno.
; [ START CODE ]
Graphics 640,480,0,2
xpos = 100
ypos = 10
hero = CreateImage(20,70)
terra = CreateImage(640,480)
SeedRnd MilliSecs()
; crea terreno
yline = 300
For xx = 0 To 31
y=Rand(-30,30)
Line xx*20,yline,xx*20+20,yline+y
Line xx*20,yline+1,xx*20+20,yline+y+1
Line xx*20,yline+2,xx*20+20,yline+y+2
yline = yline + y
Next
GrabImage terra,0,0
;crea eroe
Oval 50,50,20,20,0
Rect 50,70,20,50,0
GrabImage hero,50,50
Repeat
Cls
DrawImage hero,xpos,ypos
DrawImage terra,0,0
If ImagesCollide(hero,xpos,ypos,0,terra,0,0,0)
ypos = ypos - 2
Else
ypos = ypos + 2
EndIf
Flip
Until KeyDown(1)
End
; [ END CODE ] |
|
| |
|
|
 |
Gio Ott 12, 2006 4:28 pm |
 |
Autore |
Messaggio |
SideExtreme
Registrato: 24/10/05 15:40 Messaggi: 343
|
| Oggetto: |
|
|
Il modo più pratico è memorizzare la coordinata y attuale e quella appena precedente, dopo di che se rileva collisione aggiorni posizione attuale con quella precedente. Ricorda anche di disegnare il giocatore e il terreno dopo aver effettuato i controlli.
| Codice: |
;[ START CODE ]
Graphics 640,480,0,2
xpos = 100
ypos = 10
hero = CreateImage(20,70)
terra = CreateImage(640,480)
SeedRnd MilliSecs()
; crea terreno
yline = 300
For xx = 0 To 31
y=Rand(-30,30)
Line xx*20,yline,xx*20+20,yline+y
Line xx*20,yline+1,xx*20+20,yline+y+1
Line xx*20,yline+2,xx*20+20,yline+y+2
yline = yline + y
Next
GrabImage terra,0,0
;crea eroe
Oval 50,50,20,20,0
Rect 50,70,20,50,0
GrabImage hero,50,50
Repeat
Cls
mem_ypos = ypos ; <- memorizza coordinata Y
ypos = ypos + 2 ; coordinata Y corrente
; se rileva collisione aggiorna con vecchia coordinata
If ImagesCollide(hero,xpos,ypos,0,terra,0,0,0)
ypos = mem_ypos
EndIf
DrawImage hero,xpos,ypos
DrawImage terra,0,0
Flip
Until KeyDown(1)
End
; [ END CODE ] |
|
|
| |
|
|
 |
Gio Ott 12, 2006 6:29 pm |
 |
Autore |
Messaggio |
Rafery

Registrato: 05/05/05 20:55 Messaggi: 37 Residenza: Sauze d'Oulx
|
| Oggetto: |
|
|
SideExtreme il problema che volevo risolvere lo noti se provi a eseguire
questo codice cosi' capisci dov'e' il problema.
| Codice: |
Graphics 640,480,0,2
xpos = 100
ypos = 10
hero = CreateImage(20,70)
terra = CreateImage(640,480)
SeedRnd MilliSecs()
; crea terreno
yline = 300
For xx = 0 To 31
y=Rand(-30,30)
Line xx*20,yline,xx*20+20,yline+y
Line xx*20,yline+1,xx*20+20,yline+y+1
Line xx*20,yline+2,xx*20+20,yline+y+2
yline = yline + y
Next
GrabImage terra,0,0
;crea eroe
Oval 50,50,20,20,0
Rect 50,70,20,50,0
GrabImage hero,50,50
Repeat
Cls
mem_ypos = ypos ; <- memorizza coordinata Y
ypos = ypos + 2 ; coordinata Y corrente
; se rileva collisione aggiorna con vecchia coordinata
If ImagesCollide(hero,xpos,ypos,0,terra,0,0,0)
ypos = mem_ypos
EndIf
If KeyDown(205) Then xpos = xpos + 2
If KeyDown(203) Then xpos = xpos - 2
DrawImage hero,xpos,ypos
DrawImage terra,0,0
Flip
Until KeyDown(1)
End
|
|
|
| |
|
|
 |
Gio Ott 12, 2006 7:03 pm |
 |
Autore |
Messaggio |
Rafery

Registrato: 05/05/05 20:55 Messaggi: 37 Residenza: Sauze d'Oulx
|
| Oggetto: |
|
|
L'ho rifatto cosi' si capisce meglio.
| Codice: |
Graphics 640,480,0,2
xpos = 100
ypos = 10
hero = CreateImage(20,70)
terra = CreateImage(640,480)
SeedRnd MilliSecs()
; make terrain
yline = 300
For xx = 0 To 31
y=Rand(-30,30)
Line xx*20,yline,xx*20+20,yline+y
Line xx*20,yline+1,xx*20+20,yline+y+1
Line xx*20,yline+2,xx*20+20,yline+y+2
yline = yline + y
Next
GrabImage terra,0,0
; make Hero
Oval 50,50,20,20,0
Rect 50,70,20,50,0
GrabImage hero,50,50
Repeat
Cls
Text 0,0,"SPACE BAR TO CHANGE COLLISION"
If swap = 0
mem_ypos = ypos ; <- memorizza coordinata Y
ypos = ypos + 2 ; coordinata Y corrente
If ImagesCollide(hero,xpos,ypos,0,terra,0,0,0)
ypos = mem_ypos
EndIf
EndIf
If swap = 1
If ImagesCollide(hero,xpos,ypos,0,terra,0,0,0)
ypos = ypos - 2
Else
ypos = ypos + 2
EndIf
EndIf
If KeyDown(57)
If swap = 0
swap = 1
Else
swap = 0
EndIf
FlushKeys()
EndIf
If KeyDown(205) Then xpos = xpos + 2
If KeyDown(203) Then xpos = xpos - 2
DrawImage hero,xpos,ypos
DrawImage terra,0,0
Flip
Until KeyDown(1)
End
|
|
|
| |
|
|
 |
Gio Ott 12, 2006 9:50 pm |
 |
Autore |
Messaggio |
SideExtreme
Registrato: 24/10/05 15:40 Messaggi: 343
|
| Oggetto: |
|
|
prova questo
| Codice: |
;[ START CODE ]
Graphics 640,480,0,2
xpos = 100
ypos = 10
hero = CreateImage(20,70)
terra = CreateImage(640,480)
SeedRnd MilliSecs()
; crea terreno
yline = 300
For xx = 0 To 31
y=Rand(-30,30)
Line xx*20,yline,xx*20+20,yline+y
Line xx*20,yline+1,xx*20+20,yline+y+1
Line xx*20,yline+2,xx*20+20,yline+y+2
yline = yline + y
Next
GrabImage terra,0,0
;crea eroe
Oval 50,50,20,20,0
Rect 50,70,20,50,0
GrabImage hero,50,50
Repeat
Cls
key = 0
If KeyDown(205) Then xpos = xpos + 2 key = 1
If KeyDown(203) Then xpos = xpos - 2 key = 1
memy = ypos
ypos = ypos + 2
; se rileva collisione aggiorna con vecchia coordinata
If ImagesCollide(hero,xpos,ypos,0,terra,0,0,0)
If key = 0 ypos = memy
If key = 1 ypos = ypos - 4
EndIf
DrawImage hero,xpos,ypos
DrawImage terra,0,0
Flip
Until KeyDown(1)
End
; [ END CODE ]
|
|
|
| |
|
|
 |
Gio Ott 12, 2006 9:54 pm |
 |
Autore |
Messaggio |
Rafery

Registrato: 05/05/05 20:55 Messaggi: 37 Residenza: Sauze d'Oulx
|
| Oggetto: |
|
|
Meraviglioso.
Sei un grande |
|
| |
|
|
 |
Sab Ott 14, 2006 7:37 pm |
 |
Autore |
Messaggio |
Rafery

Registrato: 05/05/05 20:55 Messaggi: 37 Residenza: Sauze d'Oulx
|
| Oggetto: |
|
|
Avevo esposto il mio problema anche sul sito di blitzbasic
e un guru del 2D mi ha dato questo codice.
Se a qualcuno puo' servire:
| Codice: |
Graphics 640,480,0,2
SetBuffer BackBuffer()
xpos = 100
ypos = 10
hero = CreateImage(20,70)
terra = CreateImage(640,480)
SeedRnd MilliSecs()
; make terrain
yline = 300
For xx = 0 To 31
y=Rand(-30,30)
Line xx*20,yline,xx*20+20,yline+y
Line xx*20,yline+1,xx*20+20,yline+y+1
Line xx*20,yline+2,xx*20+20,yline+y+2
yline = yline + y
Next
GrabImage terra,0,0
; make Hero
Oval 50,50,20,20,0
Rect 50,70,20,50,0
GrabImage hero,50,50
Repeat
Cls
Text 0,0,"SPACE BAR TO CHANGE COLLISION "+swap
If swap = 0
ypos = ypos + 2
;move up until the hero is out of the terrain
While ImagesCollide(hero,xpos,ypos,0,terra,0,0,0)
ypos = ypos - 1
Wend
EndIf
If swap = 1
If ImagesCollide(hero,xpos,ypos,0,terra,0,0,0)
ypos = ypos - 2
Else
ypos = ypos + 2
EndIf
EndIf
If KeyHit(57)
If swap = 0
swap = 1
Else
swap = 0
EndIf
EndIf
If KeyDown(205) Then xpos = xpos + 2
If KeyDown(203) Then xpos = xpos - 2
DrawImage hero,xpos,ypos
DrawImage terra,0,0
Flip
Until KeyDown(1)
End
|
Ciao. |
|
| |
|
|
Non puoi inserire nuovi argomenti Non puoi rispondere a nessun argomento Non puoi modificare i tuoi messaggi Non puoi cancellare i tuoi messaggi Non puoi votare nei sondaggi
|
|
|
|