Sprite help
Author |
Message |
warsame
|
Posted: Sun Aug 23, 2009 3:50 pm Post subject: Sprite help |
|
|
I was playing around with sprites. I created one which can run and jump. The problem is that when I jump i cant move in the air. I tried but i cant seem to make it work. Help would be appreciated. I have also attached my work.Need help Plz and Thank you.
Description: |
This holds the program and sprites |
|
 Download |
Filename: |
kakashi.rar |
Filesize: |
661.23 KB |
Downloaded: |
88 Time(s) |
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
DemonWasp
|
Posted: Sun Aug 23, 2009 6:28 pm Post subject: RE:Sprite help |
|
|
There seems to be something wrong with the forum download mechanism - it shows your .rar as 661.23 KB, but when I download it, it's only 22 KB and won't open as an archive.
It's easier if you just post your code in [ syntax = " Turing " ] code goes here [ / syntax ] blocks - without all those extra spaces.
|
|
|
|
|
 |
Tony

|
Posted: Sun Aug 23, 2009 6:43 pm Post subject: RE:Sprite help |
|
|
Have you checked the contents of that 22 KB file?
Quote:
The selected Attachment does not exist anymore
404 File Not Found: The File kakashi_538.rar does not exist.
Posting code inline is fine, as long as it's short. Just post the relevant part(s).
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
 |
warsame
|
Posted: Mon Aug 24, 2009 9:42 am Post subject: Re: Sprite help |
|
|
Sorry for late response(Computer sucks) . Well after going through my work i noticed that the problem is that the program cant distinguish the difference key presses.
Example
left arrow= run left
right arrrow =run right
down arrow=crouch
up arrow =jump
down+right=crouch walk to the right
I had also put flags for each movement for troubleshooting. I had found that if i press down+right the sprite would just run to the right. But the crouch walk flag was put up.
if it would help here is the code. It is quite long
Turing: |
View.Set ("offscreenonly")
var keys : array char of boolean
var spriteID, x, y, y2, i, i2, i3, i4, i5, lnr : int
var stance : int := Pic.FileNew ("stance.bmp")
var stance2 : int := Pic.FileNew ("stance2.bmp")
var run : array 1 .. 6 of int
var runl : array 1 .. 6 of int
var jumpr : array 1 .. 3 of int
var jumpl : array 1 .. 3 of int
var crouch : array 1 .. 2 of int
var crouchwalk : array 1 .. 6 of int
crouchwalk (1) := Pic.FileNew ("cw0.bmp")
crouchwalk (2) := Pic.FileNew ("cw1.bmp")
crouchwalk (3) := Pic.FileNew ("cw2.bmp")
crouchwalk (4) := Pic.FileNew ("cw3.bmp")
crouchwalk (5) := Pic.FileNew ("cw4.bmp")
crouchwalk (6) := Pic.FileNew ("cw5.bmp")
crouch (1) := Pic.FileNew ("c1.bmp")
crouch (2) := Pic.FileNew ("c2.bmp")
jumpr (1) := Pic.FileNew ("j1.bmp")
jumpr (2) := Pic.FileNew ("j2.bmp")
jumpr (3) := Pic.FileNew ("j3.bmp")
jumpl (1) := Pic.FileNew ("jl1.bmp")
jumpl (2) := Pic.FileNew ("jl2.bmp")
jumpl (3) := Pic.FileNew ("jl3.bmp")
run (1) := Pic.FileNew ("kr0.bmp")
run (2) := Pic.FileNew ("kr1.bmp")
run (3) := Pic.FileNew ("kr2.bmp")
run (4) := Pic.FileNew ("kr3.bmp")
run (5) := Pic.FileNew ("kr4.bmp")
run (6) := Pic.FileNew ("kr5.bmp")
runl (1) := Pic.FileNew ("kl0.bmp")
runl (2) := Pic.FileNew ("kl1.bmp")
runl (3) := Pic.FileNew ("kl2.bmp")
runl (4) := Pic.FileNew ("kl3.bmp")
runl (5) := Pic.FileNew ("kl4.bmp")
runl (6) := Pic.FileNew ("kl5.bmp")
x := 100
y := 100
i := 0
i2 := 0
lnr := 0
i4 := 0
i5 := 1
proc crouchwalking
if i4 = 2 then
i5 := i5 + 1
end if
if i5 = 7 then
i5 := 1
end if
Sprite.Animate (spriteID, crouchwalk (i5 ), x, y, false)
Sprite.Show (spriteID )
View.Update
delay (10)
cls
end crouchwalking
proc crouching
if keys (KEY_RIGHT_ARROW) then
x := x + 1
if i4 = 2 then
i5 := i5 + 1
end if
if i5 = 7 then
i5 := 1
end if
Sprite.Animate (spriteID, crouchwalk (i5 ), x, y, false)
Sprite.Show (spriteID )
View.Update
delay (10)
cls
end if
if i4 not= 2 then
i4 := i4 + 1
end if
Sprite.Animate (spriteID, crouch (i4 ), x, y, false)
Sprite.Show (spriteID )
View.Update
delay (150)
cls
end crouching
proc runr
x := x + 10
if i = 6 then
i := 0
end if
i := i + 1
Sprite.Animate (spriteID, run (i ), x, y, false)
Sprite.Show (spriteID )
View.Update
delay (100)
cls
Sprite.ChangePic (spriteID, stance )
end runr
proc krunl
x := x - 10
if i2 = 6 then
i2 := 0
end if
i2 := i2 + 1
Sprite.Animate (spriteID, runl (i2 ), x, y, false)
Sprite.Show (spriteID )
View.Update
delay (100)
cls
Sprite.ChangePic (spriteID, stance2 )
end krunl
proc kjr
loop
if keys (KEY_LEFT_ARROW) then
x := x - 1
lnr := 1
end if
if keys (KEY_RIGHT_ARROW) then
x := x + 1
lnr := 2
end if
put y
y := y + 1
if y = 2 then
i3 := 1
end if
if y > 2 then
i3 := 2
end if
if lnr = 1 then
Sprite.Animate (spriteID, jumpl (i3 ), x, y, false)
end if
if lnr = 2 then
Sprite.Animate (spriteID, jumpr (i3 ), x, y, false)
end if
Sprite.Show (spriteID )
View.Update
delay (5)
cls
exit when y = 150
end loop
end kjr
proc landing
loop
if keys (KEY_LEFT_ARROW) then
x := x - 1
lnr := 1
end if
if keys (KEY_RIGHT_ARROW) then
x := x + 1
lnr := 2
end if
put y
y := y - 1
if y = 101 then
i3 := 3
end if
if lnr = 1 then
Sprite.Animate (spriteID, jumpl (i3 ), x, y, false)
end if
if lnr = 2 then
Sprite.Animate (spriteID, jumpr (i3 ), x, y, false)
end if
Sprite.Show (spriteID )
View.Update
delay (5)
cls
exit when y = 100
end loop
end landing
spriteID := Sprite.New (stance )
Sprite.Show (spriteID )
View.Update
loop
put i5
Input.KeyDown (keys )
if keys (KEY_UP_ARROW) then
kjr
landing
end if
if keys (KEY_DOWN_ARROW) then
crouching
end if
if keys (KEY_LEFT_ARROW) then
krunl
end if
if keys (KEY_RIGHT_ARROW) then
runr
end if
end loop
|
|
|
|
|
|
 |
tjmoore1993

|
Posted: Wed Aug 26, 2009 2:28 pm Post subject: RE:Sprite help |
|
|
Can you reupload what you have? Maybe I can assist you.
|
|
|
|
|
 |
Tony

|
Posted: Wed Aug 26, 2009 3:18 pm Post subject: RE:Sprite help |
|
|
The problem is that you check your input all over the place. keys (KEY_RIGHT_ARROW) is checked for 4 times in your code.
The actual problem though, is that in your main loop, all UP/DOWN LEFT/RIGHT are not mutually exclusive (if-end, if-end as oppose to if-elsif-end). As such, DOWN+RIGHT satisfies both crouching and runr, so the character does both in the same frame.
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
 |
warsame
|
Posted: Wed Aug 26, 2009 4:44 pm Post subject: Re: Sprite help |
|
|
Heres the upload if it would help. Also i was looking at the Bsprite module and i was thinking maybe i should scrap everything and make a new one with the bsprite. Jus looking for help.
Description: |
|
 Download |
Filename: |
kakashi.rar |
Filesize: |
661.23 KB |
Downloaded: |
78 Time(s) |
|
|
|
|
|
 |
tjmoore1993

|
Posted: Thu Aug 27, 2009 4:52 pm Post subject: Re: Sprite help |
|
|
I've found your programming a bit to hard to comprehend. I thought I might give it a shot, although there are some known glitches/bugs with movement. I think you can tune that.
Description: |
|
 Download |
Filename: |
kakashi.zip |
Filesize: |
652.72 KB |
Downloaded: |
123 Time(s) |
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
warsame
|
Posted: Fri Aug 28, 2009 4:42 pm Post subject: RE:Sprite help |
|
|
WOW Thank you so much. Yes now that you labeled and organized my work i can fix the glitches. I hope one day i can return the favor.
|
|
|
|
|
 |
tjmoore1993

|
Posted: Sat Aug 29, 2009 10:04 am Post subject: Re: RE:Sprite help |
|
|
warsame @ Fri Aug 28, 2009 4:42 pm wrote: WOW Thank you so much. Yes now that you labeled and organized my work i can fix the glitches. I hope one day i can return the favor.
Turing isn't that great of a language since it lacks a lot of potential. Don't worry about it, I made sure that I only spent 15 minutes on it.
|
|
|
|
|
 |
Kharybdis

|
Posted: Sun Sep 06, 2009 8:44 am Post subject: RE:Sprite help |
|
|
When using sprites, you should create a function that does the picture name assigning for you. It's very long to do ex. crouchwalk (1) := Pic.FileNew ("cw0.bmp") each time..
|
|
|
|
|
 |
|
|