I read this post, and I wanted to try to do something like that. So, in ~2½ hours, I coded this. My code is a mess ( I don't like love.update() ), and graphics are even worse, but it works.
In the top-left corner I put an HP bar (just in case I go on with this... thing) and a fuel bar, that replenish itself while standing still. Spacebar decreases HP by 10 and fuel by 90%, and ↓ set both to 100%.
EDIT: I missed a 0 (so ↓ only set fuel to 10%) and forgot to change window's title
SCR Move - SinCosRadMove
SCR Move - SinCosRadMove
- Attachments
-
- SinCosRadMove.love
- (2.98 KiB) Downloaded 253 times
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
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: SCR Move - SinCosRadMove
Nice.
Here's an exercise for you: it looks a bit like Astroid at this point. Only in space there is no friction: if there is no force working on an object it just goes on in the same direction forever. To stop or change direction, you'll need to turn and accelerate the other way. See if you can implement this.
Here's an exercise for you: it looks a bit like Astroid at this point. Only in space there is no friction: if there is no force working on an object it just goes on in the same direction forever. To stop or change direction, you'll need to turn and accelerate the other way. See if you can implement this.
Help us help you: attach a .love.
Re: SCR Move - SinCosRadMove
I improved a bit SCR Move while you were writing your post (added small deceleration and a speedometer), when I read it I wanted to go to sleep (00:40 AM in Italy). Now I've gotta go, after lunch I'll try to implement that.
P.S: I wrote "coming soon" 'cause I didn't understand how to code the speedometer (I told you, it was late ), and when I understood it I didn't have the time to cancel the writing.
EDIT: forgot the attachment
EDIT: too many of them
P.S: I wrote "coming soon" 'cause I didn't understand how to code the speedometer (I told you, it was late ), and when I understood it I didn't have the time to cancel the writing.
EDIT: forgot the attachment
EDIT: too many of them
- Attachments
-
- SinCosRadMove.love
- (28.4 KiB) Downloaded 175 times
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: SCR Move - SinCosRadMove
Neat! Looks good so far.
You probably noticed things don't look quite right when turning at high speeds. If you're going for an asteroids-feel where you drift along and rotate freely without turning like an airplane, you'll want the thrust to control acceleration instead of velocity.
What I mean is...
Try this and you'll find that using forces in addition to storing the velocity makes for much more realistic motion.
You probably noticed things don't look quite right when turning at high speeds. If you're going for an asteroids-feel where you drift along and rotate freely without turning like an airplane, you'll want the thrust to control acceleration instead of velocity.
What I mean is...
Code: Select all
in love.load
vx = 0
vy = 0
thrust = 10 (or some appropriate number)
end
in love.update
fx = 0 -- horizontal force
fy = 0 -- vertical force
if up key is pressed
-- rocket is firing, apply thrust
fx = fx + thrust*math.cos(angle)
fy = fy + thrust*math.sin(angle)
end
-- the thrust only modifies the velocity
vx = vx + fx*dt
vy = vy + fy*dt
-- now the resulting velocity modifies the position
x = x + vx*dt
y = y + vy*dt
end
Re: SCR Move - SinCosRadMove
I was thinking about something like that... Thank you
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
- josefnpat
- Inner party member
- Posts: 955
- Joined: Wed Oct 05, 2011 1:36 am
- Location: your basement
- Contact:
Re: SCR Move - SinCosRadMove
This is very very smooth, nice job!
May I suggest you round the percentage below the health bar and the speed on the spedometer
Also, alias the the throttle image (the thing that shows how fast you're going).
May I suggest you round the percentage below the health bar and the speed on the spedometer
Also, alias the the throttle image (the thing that shows how fast you're going).
Missing Sentinel Software | Twitter
FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push
FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push
Re: SCR Move - SinCosRadMove
Nixola, good work in engine but I have the feeling that you are using the wrong anchor point to rotate your ship (or you are not updating well that point). The rotation of the ship don't feel natural and ship isn't really rotating but like circle outside-facing around one point at the back of the ship. Or you really wish a rotation like this?
Re: SCR Move - SinCosRadMove
The point is the center of the ship (ship: 32x32px, offset: 16, 16), now II'm working on this post, I rewrited everything and controlled it at least 15 times, but I can't make the ship move like this
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: SCR Move - SinCosRadMove
After 3 days hunting an error, I found a "math.sin" instead of a "math.cos" ( ), I named this new version "SCR Asteroids", even if there aren't asteroids (for now). I'll draw a better ship (maype ) and implement enemies spaceships. Until then, don't press spacebar. DON'T.
- Attachments
-
- SCR Asteroids.love
- (28.78 KiB) Downloaded 206 times
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: SCR Move - SinCosRadMove
Sweet! You've got it! That type of motion works really well and has a very spacey feel.
Who is online
Users browsing this forum: No registered users and 3 guests