I need help with a Zelda Game
Author |
Message |
Barda4
|
Posted: Sat Jan 13, 2007 3:04 pm Post subject: I need help with a Zelda Game |
|
|
I'm doing my final project for my 10gr. class, and I'm making a Legend Of Zelda Game. Now I am still pretty new at this, and i was wondering if there is a way to make it so that, link will swing his sword in the direction he is facing, by pressing a single button. Right now I have it so that "A" swings Left, "W" swings Up, "S" swings Down, "D" swinds Right.
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Cervantes

|
Posted: Sat Jan 13, 2007 3:55 pm Post subject: RE:I need help with a Zelda Game |
|
|
Sure there is. You just need to keep a variable for the direction that link is facing. It could be an integer variable, perhaps: 0 for down, 1 for up, 2 for left, 3 for right. Or perhaps you could use strings. It's up to you.
Then when you attack, just find the square in front of Link and attack whatever is in that square. So if Link is at (x, y) and he is facing direction "up", then he attacks square (x, y + 1).
|
|
|
|
|
 |
Ultrahex
|
Posted: Sat Jan 13, 2007 4:02 pm Post subject: Re: I need help with a Zelda Game |
|
|
you may need a little bit of trigonometry, for rotation of the unit, and you need to remeber which way the unit is looking also. if you want a rotational unit.
If you do not want a rotational unit then just make a variable as the way you are looking and attack in that direction, check the way you are looking variable when you turn, and in your attack check direction.
Here is an example using trigonometry for a rotational Unit:
code: | % create object type
type obj :
record
angle : real
x : real
y : real
end record
View.Set ("offscreenonly")
var chars : array char of boolean
%create unit
var hex : obj
hex.angle := 0
hex.x := 50
hex.y := 50
var attackFrame : int := -25
loop
put "a,w,s,d are movment keys"
put "q attacks"
Input.KeyDown (chars)
% Movement Keys
if chars ('a') then
% Rotate Left
hex.angle += 1
end if
if chars ('d') then
% Rotate Right
hex.angle -= 1
end if
if chars ('w') then
% Move Forward
hex.x += cosd (hex.angle)
hex.y += sind (hex.angle)
end if
if chars ('s') then
% Move Forward
hex.x -= cosd (hex.angle)
hex.y -= sind (hex.angle)
end if
% Attack
if (chars ('q')) or (attackFrame not= -25) then
Draw.ThickLine (round (hex.x), round (hex.y), round (hex.x + 20 * cosd (hex.angle + attackFrame)), round (hex.y + 20 * sind (hex.angle + attackFrame)),3, blue)
attackFrame += 1
if (attackFrame = 25) then
attackFrame := -25
end if
end if
%Draw Of Unit and Direction
drawfillbox (round (hex.x - 5), round (hex.y - 5), round (hex.x + 5), round (hex.y + 5), red)
drawline (round (hex.x), round (hex.y), round (hex.x + 20 * cosd (hex.angle)), round (hex.y + 20 * sind (hex.angle)), red)
%Update Screen, Clear, And Delay
View.Update
delay (10)
cls
end loop |
|
|
|
|
|
 |
wtd
|
Posted: Sat Jan 13, 2007 4:16 pm Post subject: RE:I need help with a Zelda Game |
|
|
What about using an enumerated type for the direction?
|
|
|
|
|
 |
BenLi

|
Posted: Sat Jan 13, 2007 4:37 pm Post subject: RE:I need help with a Zelda Game |
|
|
guys guys, I think you guys are going beyond the subject. All the things you guys mentioned would be nice, but it would have to learned to be sure.
and to Barda4: I'm not discouraging you at all from trying to make zelda, but have you considered all the things that need to happen in order to make this game? It may be harder than you think.
Here are some of the things that I can think of that you would have to know:
- subroutines
- real-time programming
- arrays (multidimensional is best)
- outputting and reading to and from text files
- sprites?
if you don't know these yet, I suggest you familarize yourself with them BEFORE you start coding. Coding the right way is easier than going back and overhauling your code. The best of luck.
|
|
|
|
|
 |
Barda4
|
Posted: Sat Jan 13, 2007 10:00 pm Post subject: Re: I need help with a Zelda Game |
|
|
Ok here is the game, and all of the sprites that u need. Maybe then u can help show me what to do, because I'm not quite understanding the jist what u guys are saying.
|
|
|
|
|
 |
Barda4
|
Posted: Sat Jan 13, 2007 10:02 pm Post subject: Re: I need help with a Zelda Game |
|
|
Srry the last post didn't attach the file
Description: |
|
 Download |
Filename: |
Link Animation.zip |
Filesize: |
168.01 KB |
Downloaded: |
73 Time(s) |
|
|
|
|
|
 |
CodeMonkey2000
|
Posted: Sat Jan 13, 2007 10:17 pm Post subject: RE:I need help with a Zelda Game |
|
|
AHH use arrays and for loops!! zyour code is too long. any way I would check if the enemy is in front of me (in relation to the way you are faceing). if he is and you are stricking, and the two pictures are collideing then the enemy has been hit. it may not be accurate but it will look good enough.
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
|
|