Re: Mouse and graphics
- Posted by Undetermined origin c/o LISTSERV administrator Aug 06, 2000
- 364 views
Paul Kerslake wrote: > I'd like to thank you all for giving me some help. But, it seems the deeper > into Euphoria I get, the more problems I get. There's a Genisis song I'd > contribute to programming, that song being Land of Confusion! But, hey, I'm new > so, that's probably normal. > > Here's are the new problems: > > Is there some way of using get_mouse() and converting it into a sequence so I > can use it in things like position or draw_line? > eg: > > include mouse.e > include graphics.e > > integer junk > object mouse > junk=graphics_mode(18) > while get_key()=-1 do > mouse = get_mouse() > if sequence(mouse) then > if mouse[1] = LEFT_DOWN then > puts(1, "You left clicked yourr mouse at: " & sprintf("%3d",mouse[2]) & "," & > sprintf("%3d\n", mouse[3])) > > elsif mouse[1] = RIGHT_DOWN then > draw_line(mouse[2],mouse[3]) > end if > end if > end while For a line, you need at least 2 points. get_mouse only returns the point where the mouse is. Here's an example which should draw a line between two or more clicks: integer junk object prev_mouse, mouse prev_mouse = 0 while get_key() = -1 do mouse = get_mouse() if sequence(mouse) then if mouse[1] = LEFT_DOWN then if integer(prev_mouse) then prev_mouse = mouse[2..3] else draw_line(WHITE,{mouse[2..3],prev_mouse}) prev_mouse = mouse[2..3] end if end if end if end while > This would result in a program (or something) that, when a mouse button is > clicked, a line is drawn at it's co-ords. > > Here's a biggie: I know how to make a program that can move an image (text or > bitmap) around the screen using the arrow keys (or any other key fot that > matter), but, how can I have frames? > > e.g. > Having a bitmap of a space-ship and, when it moves, animate the fire coming > out the back. > (Gee, can we tell what kind of programs I'm going for?) What exactly do you mean? I mean, are you wondering about blitting the images to the screen or timing the frames of an animation or what? Jeffrey Fielding JJProg at cyberbury.net