Computer Science Canada

Slowing Movement with custom-made Joystick

Author:  xHoly-Divinity [ 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

Author:  Flikerator [ Tue Feb 22, 2005 4:01 pm ]
Post 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.

Author:  cool dude [ Tue Feb 22, 2005 4:05 pm ]
Post subject: 

i would just put a delay in it because forks are bad and i suggest not to use them.

Author:  Flikerator [ Tue Feb 22, 2005 4:07 pm ]
Post 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..

Author:  xHoly-Divinity [ Tue Feb 22, 2005 4:07 pm ]
Post 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. Confused Anything else? (P.S. can you explain to me the fork method)

Author:  Flikerator [ Tue Feb 22, 2005 4:31 pm ]
Post 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.

Author:  xHoly-Divinity [ Tue Feb 22, 2005 4:34 pm ]
Post 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

Author:  Flikerator [ Tue Feb 22, 2005 4:41 pm ]
Post 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 Razz

Author:  xHoly-Divinity [ Tue Feb 22, 2005 5:56 pm ]
Post 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 Confused , there has got to be another way?!!!!!???

Author:  Flikerator [ Tue Feb 22, 2005 7:01 pm ]
Post 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.

Author:  Bacchus [ Tue Feb 22, 2005 11:00 pm ]
Post 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

Author:  xHoly-Divinity [ Wed Feb 23, 2005 5:09 pm ]
Post 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 Very Happy

Author:  Flikerator [ Wed Feb 23, 2005 5:41 pm ]
Post subject: 

Mabey try a ship game of some sort? I never use a joystick so I can't really help you there Razz

Author:  mike200015 [ Wed Feb 23, 2005 5:55 pm ]
Post 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? Idea

Author:  xHoly-Divinity [ Wed Feb 23, 2005 6:19 pm ]
Post subject: 

I will do both, trust me. I'll give you the end result when i'm done Wink ! Keep these ideas comming, i'm liking this!!!

Author:  mike200015 [ Wed Feb 23, 2005 6:26 pm ]
Post subject: 

Laughing lol.. sounds good!

Author:  xHoly-Divinity [ Wed Feb 23, 2005 6:43 pm ]
Post subject: 

I was wondering (I am starting with a boat shooting game) a few things. For the bg could I make it move up vertically just the same way it moves horizontally. Also, I'm wondering if it is possible to have multiple inputs at a time e.g. to be holding and moving the joystick and at the same time be pressing space to fire a missile?

Author:  mike200015 [ Wed Feb 23, 2005 9:02 pm ]
Post subject: 

xHoly-Divinity wrote:
For the bg could I make it move up vertically just the same way it moves horizontally.


What do you mean by makin the bg move up vertically / horizontally Question

Author:  xHoly-Divinity [ Thu Feb 24, 2005 3:53 pm ]
Post subject: 

What i meen by moving the background, is that the bg scrolls up as you move up. E.g. like in super mario as you move to the left, the background/screen moves left with him

Author:  mike200015 [ Thu Feb 24, 2005 5:09 pm ]
Post subject: 

ooo.. kk.. got it, but it doesnt technically have to be the bg moving, jus the objects that are in the bg, (ie.shapes in the bg, just make them move..)

Author:  xHoly-Divinity [ Thu Feb 24, 2005 5:16 pm ]
Post subject: 

Alright, but would you mind elaborating on that a bit please Smile

Author:  mike200015 [ Thu Feb 24, 2005 5:24 pm ]
Post subject: 

kk.. so say in a game like mario, with the blocks etc. in the background, so if you make sumthing like that, when the character gets to say maxx, and if they press the right arrow key again, then the blocks in the bg will move 1 space to the left, to seem as though you are moving right.
Sorry if i didnt explain it well, might sound a lil confusin Confused

Author:  xHoly-Divinity [ Thu Feb 24, 2005 5:27 pm ]
Post subject: 

Yeah, there's a tutorial on it. I was just asking if it would act the same way if you wanted it to go up and down as opposed to left a right?

Author:  mike200015 [ Thu Feb 24, 2005 5:39 pm ]
Post subject: 

oo, sorry. Yea i would assume so, bcuz if u would move up, you just move the shape down, and vice versa for if you move down.

Author:  xHoly-Divinity [ Thu Feb 24, 2005 6:23 pm ]
Post subject: 

Mind giving me a link to the tutorial. I remember seeing it but I can't remember where it was Confused

Author:  mike200015 [ Thu Feb 24, 2005 6:28 pm ]
Post subject: 

Sorry, havent seen the tutorial bout it. Do you know what the topic of it was, so i can search for it, n if i find it ill let you know.

Author:  xHoly-Divinity [ Thu Feb 24, 2005 6:32 pm ]
Post subject: 

I'm not 100% sure but I could have sworn it was something along the lines of "moving background", I think there was one recently called "Making background bigger than screen size" or sumfin like that. Thanks man, that would be a big help Smile

Author:  mike200015 [ Thu Feb 24, 2005 6:38 pm ]
Post subject: 

kk.. ill look for it, if i find it ill let you know

Author:  xHoly-Divinity [ Thu Feb 24, 2005 6:41 pm ]
Post subject: 

THANKS!!! Very Happy

Author:  xHoly-Divinity [ Sat Feb 26, 2005 1:10 pm ]
Post subject: 

Hey, you don't have to worry about it anymore, I found the tutorial I was looking for. I will post a copy of the game when im done so keep updated 8)

Author:  mike200015 [ Sat Feb 26, 2005 3:51 pm ]
Post subject: 

xHoly-Divinity wrote:
Hey, you don't have to worry about it anymore, I found the tutorial I was looking for. I will post a copy of the game when im done so keep updated 8)


o.. kk.. yea i was lookin i couldnt find it under the names u gave me .. can u post the tutorial Question

Author:  xHoly-Divinity [ Sat Feb 26, 2005 4:05 pm ]
Post subject: 

As soon as I'm done my game, I will MAKE a tutorial on it Razz

Author:  mike200015 [ Sat Feb 26, 2005 7:22 pm ]
Post subject: 

lol.. kk.. nice Smile

Author:  mike200015 [ Sat Feb 26, 2005 7:23 pm ]
Post subject: 

lol... kk.. nice Exclamation Very Happy

EDIT

Woops sorry, didnt mean to post that twice Confused


: