I want to make a very simple TDS (TOP-DOWN SHOOTER), and I want to position a weapon in the hand of player:
The green cross Is the point(cross!!) where the player will rotate (I arealdy solved this xDDD)
The red rectangle is where I want to position the weapon
I think if I discover how to position the weapon I can position the shoot point in the weapon( I think ...)
Wow, it's very simple, or no (i don't know how to do this )
Anyone help is welcome !!!
Srry bad english, I'm brazilian xDD
[SOLVED]Positioning a image in another image(A weap in hand)
[SOLVED]Positioning a image in another image(A weap in hand)
Last edited by Мэтю on Tue Jan 07, 2014 8:54 pm, edited 1 time in total.
World needs love.
Re: Positioning a image in another image (A weapon in a hand
You can draw the weapon on an image of the same size as the player (which would be mostly transparent) and set the origin coordinates to the same coordinates. If you keep the angle of both images the same, then the weapon will be perfectly aligned with the hand of the player.
Check out my blog on gamedev
- richardperkins
- Prole
- Posts: 9
- Joined: Tue Jan 07, 2014 6:20 am
Re: Positioning a image in another image (A weapon in a hand
As micha said, create an image the same size as the player (or bigger if you want the gun to extend past the bounds of the player image).
All you need to do then is draw it the same exact way you draw your player. No unnecessary math involved
All you need to do then is draw it the same exact way you draw your player. No unnecessary math involved
Re: Positioning a image in another image (A weapon in a hand
Also remember to add the gun's draw code under the player drawing
or the gun thingy will be under the player image
P.S: don't use "!" all the time.
Code: Select all
love.graphics.draw(playerimg,0,0)
love.graphics.draw(gunimg,0,0)
P.S: don't use "!" all the time.
Re: Positioning a image in another image (A weapon in a hand
This is the only valid suggestion, though, if you need to know the actual gun position so that you can spawn bullets there.bekey wrote:Trigonometry xDDD
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Re: Positioning a image in another image (A weapon in a hand
micha wrote:You can draw the weapon on an image of the same size as the player (which would be mostly transparent) and set the origin coordinates to the same coordinates. If you keep the angle of both images the same, then the weapon will be perfectly aligned with the hand of the player.
Yeah, it's a nice solutionrichardperkins wrote:As micha said, create an image the same size as the player (or bigger if you want the gun to extend past the bounds of the player image).
All you need to do then is draw it the same exact way you draw your player. No unnecessary math involved
Obeyiedjjmafiae wrote:P.S: don't use "!" all the time.
Now i get this :
http://schineider.hostei.com/lel.love
The bullets are spawning in incorret position
(Imagine the black line in the hand of the player is a weapon )
World needs love.
Re: Positioning a image in another image (A weapon in a hand
Solution 1: Trigonometry (if you want to do this, please tell us and we can give you some code or formulas)
Solution 2: Change the image of the player, such that he is holding the bullet centered. From what I know, this is also more realistic, since the player would aim by looking over the iron sights on top of the weapon. Then you could spawn bullets in the center of the player.
Your .love file seems to be broken. At least I cannot unpack it.
Solution 2: Change the image of the player, such that he is holding the bullet centered. From what I know, this is also more realistic, since the player would aim by looking over the iron sights on top of the weapon. Then you could spawn bullets in the center of the player.
Your .love file seems to be broken. At least I cannot unpack it.
Check out my blog on gamedev
Re: Positioning a image in another image (A weapon in a hand
The second solution is nice, im going to try now, but if you can tell me some formulas or codes about trigonometry would be nicemicha wrote:Solution 1: Trigonometry (if you want to do this, please tell us and we can give you some code or formulas)
Solution 2: Change the image of the player, such that he is holding the bullet centered. From what I know, this is also more realistic, since the player would aim by looking over the iron sights on top of the weapon. Then you could spawn bullets in the center of the player.
Your .love file seems to be broken. At least I cannot unpack it.
New file not broken (i think)
World needs love.
Re: Positioning a image in another image (A weapon in a hand
Weapon position,player rotation and shooting solved, i'll put [SOLVED] on this post
I created a simple stamina system, a simple bar of stamina and a zombie that follow the player.
Now i gonna create a system that if zombie collide with player, he takes damage, and with time, new features, each by your time xDD
I'm too excited with love engine
If u want to see what i did, download the .love file and unpack, all the code are in main.lua
EDIT:
Now stamina number don't show double or float numbers . Thanks to Doctory
The result:
I created a simple stamina system, a simple bar of stamina and a zombie that follow the player.
Now i gonna create a system that if zombie collide with player, he takes damage, and with time, new features, each by your time xDD
I'm too excited with love engine
If u want to see what i did, download the .love file and unpack, all the code are in main.lua
EDIT:
Now stamina number don't show double or float numbers . Thanks to Doctory
The result:
Last edited by Мэтю on Mon Jan 20, 2014 12:50 am, edited 2 times in total.
World needs love.
Who is online
Users browsing this forum: Ahrefs [Bot] and 8 guests