Posted: Tue Feb 22, 2005 3:54 pm Post subject: Slowing Movement with custom-made Joystick
When then joystick moves, the block moves with it, as you can see. However, the movement of the block is too fast. How can i slow it down without adding a delay. (What i tried to do was divide the bottom line by 2, but then it wouldn't be an integer value so it shows an error).
code:
setscreen ("offscreenonly")
var x, y : int := 200
var q, r : int := 400
r := 200
proc draw
drawfilloval (x, y, 30, 30, 12)
end draw
proc erase
drawfilloval (x, y, 30, 30, white)
end erase
loop
drawline (200, 200, x, y, white)
var a, b, press : int
mousewhere (a, b, press)
if whatdotcolor (a, b) = 12 and press = 1 then
if a < 300 and a > 100 and b > 100 and b < 300 then
x := a
y := b
end if
elsif press not= 1 then
x := 200
y := 200
end if
cls
if press = 1 then
q := q + (a - 200)
r := r + (b - 200)
end if
delay (100)
drawline (200, 200, x, y, black)
drawbox (q, r, q + 100, r + 100, black)
draw
View.Update
end loop
Sponsor Sponsor
Flikerator
Posted: Tue Feb 22, 2005 4:01 pm Post subject: (No subject)
Make a lot of calculation commands or something in a process and fork it a bunch of times.
code:
var num : int := 1
process lag
loop
num := num + num + num + num
num := 1
num := num + num + num + num
num := 1
num := num + num + num + num
num := 1
end loop
end lag
fork lag
fork lag
fork lag
fork lag
fork lag
fork lag
fork lag
Something to that degree.
cool dude
Posted: Tue Feb 22, 2005 4:05 pm Post subject: (No subject)
i would just put a delay in it because forks are bad and i suggest not to use them.
Flikerator
Posted: Tue Feb 22, 2005 4:07 pm Post subject: (No subject)
cool dude wrote:
i would just put a delay in it because forks are bad and i suggest not to use them.
You are trying to slow down the program without Delay..The only reason not to use a fork is because it slows down your program, are ugly, and go at different times. All of those dont really matter for what he is doing..
xHoly-Divinity
Posted: Tue Feb 22, 2005 4:07 pm Post subject: (No subject)
If i add a delay, then it becomes really laggy, and the movement isn't smooth. Also, it is VERY bad to add a lot of delay when using mousewhere because the drawing of the circle will be delayed. Anything else? (P.S. can you explain to me the fork method)
Flikerator
Posted: Tue Feb 22, 2005 4:31 pm Post subject: (No subject)
Well if you make a process and then fork it it will slow down your program. The more things in the process the slower it will be. Given its not the best method it works best with a loop. I prefer to use delay but if you dont want to just have a lot of forks.
xHoly-Divinity
Posted: Tue Feb 22, 2005 4:34 pm Post subject: (No subject)
Alright, thanks. I was just wondering if it was possible to set something at decimal coordinates e.g. drawbox (50.5, 30.5, 100, 100, black). If it's possible then plz do tell
Flikerator
Posted: Tue Feb 22, 2005 4:41 pm Post subject: (No subject)
xHoly-Divinity wrote:
Alright, thanks. I was just wondering if it was possible to set something at decimal coordinates e.g. drawbox (50.5, 30.5, 100, 100, black). If it's possible then plz do tell
Nope its not possible. You can't have somethign on Half a pixel
Sponsor Sponsor
xHoly-Divinity
Posted: Tue Feb 22, 2005 5:56 pm Post subject: (No subject)
I made a new version of the program using fork, however, utilizing fork in the way that it is is no different from using delay. GRRRRR , there has got to be another way?!!!!!???
Flikerator
Posted: Tue Feb 22, 2005 7:01 pm Post subject: (No subject)
Use a cooldown. That would probably work, talk to "Cervantes" on how to do cooldown, im not entirely sure how to do such a thing yet. Hopefully he won't hate meh for telling people to ask him for help and askign for help myself lolz.
Bacchus
Posted: Tue Feb 22, 2005 11:00 pm Post subject: (No subject)
change this part:
code:
if press = 1 then
q += round((x-200)/2)
r += round((y-200)/2)
end if
thats basically the distance from the starting points of the joystick to the new position divided by 2 (and rounded to make it an int) that way more lean stick in one direction faster will go
xHoly-Divinity
Posted: Wed Feb 23, 2005 5:09 pm Post subject: (No subject)
Wow!! Thanks man, that's good stuff. Well just to show you what the final code of the joystick movement is. I was wondering if you guys can give me an idea of how to apply it to some sort of game, because that would be awesome. I was thinking of some sort of "moving background game".
P.S. Yes, I've already looked at the game ideas section, but most of them don't really apply to this and I want something original. It would be of great help, if you could offer your suggestions
Flikerator
Posted: Wed Feb 23, 2005 5:41 pm Post subject: (No subject)
Mabey try a ship game of some sort? I never use a joystick so I can't really help you there
mike200015
Posted: Wed Feb 23, 2005 5:55 pm Post subject: (No subject)
Another idea.. you could do a target practice type game, and you move around with the joystick and shoot the targets by pressing the buttons?
xHoly-Divinity
Posted: Wed Feb 23, 2005 6:19 pm Post subject: (No subject)
I will do both, trust me. I'll give you the end result when i'm done ! Keep these ideas comming, i'm liking this!!!