Am 22.12.2012 um 20:48 schrieb Dilwyn Jones:

> May I take the opportunity to wish everyone on this list a Merry Christmas.
> 
> I have been trying to write what I thought would be a simple point and shoot 
> game in BASIC using Easyptr. The mouse controls a pointer which shoots at the 
> moving target using a routine similar to the much simplifed code below which 
> I hope will adequately explain what I am trying and failing to achieve
> 
> OUTLN #0
> REPeat loop
> RDPT #0, tvec%,xpos%,ypos%,time%
> IF mouse button down and pointer position is same as target
>  hit routine, score etc
> END IF
> move target position (simple animation only)
> END REP loop
> 
> Don’t worry about the undefined variables in the RDPT command, I just omitted 
> them to keep the skeleton program short. tvec% is just the termination 
> vector, xpos% and ypos% are pointer position set and return values and time% 
> is a timeout (0 or other low value).
> 
> The problem is unexpected, but I think I see why it’s happening and I need to 
> find a different way of writing this.
> 
> The pointer appears during the RDPT command (which reads the keyboard with 
> either zero timeout or very short timeout as a simple speed control 
> mechanism) and disappears between the RDPT command and the end of the loop, 
> so the pointer flashes a lot. In fact with a timeout of zero or close to zero 
> the pointer doesn’t appear at all (presumably loop iteration is faster on 
> QPC2 than the screen refresh can keep up with). The pointer arrow is seen on 
> screen far less than it is invisible.
> 
> What I need to achieve of course is a steady pointer which doesn’t flash on 
> and off so irritatingly.
> 
> I have considered and tried:
> 
> 1. A pointer of 0x0 pixels in size
> 2. A transparent pointer
> 
> and in both cases keep reading pointer position and draw my own little 
> cross-hair pointer at that position in place of the system pointer. In all 
> cases it either fails completely with no error message or even drawing my own 
> pointer is very jerky and doesn’t really keep up with pointer movement which 
> as you can imagine in a game like this can be pretty quick at times.
> 
> Anyone got any more ideas as to how I might go about this in a different way 
> perhaps? Or what I might be doing wrong?
> 
> The game itself is basically a set of jack-in-the-boxes popping up in random 
> places which you have to “splat” with the pointer to hit as many as you can 
> in half a minute.
> 

Dilwyn,

First: Merry Christmas to you and everyone else on the list!

To your question:
Why is it that you are trying to keep the RDPT timeout short? It should be as 
/long/ as possible, because the PTR environment is much better at drawing the 
mouse pointer at current mouse coordinates than your program, obviously.
I would try a logic like that one:

REPEAT
  timeout = RND(whenever the next jack-in-the-box should pop up)
 tvec = "Return on left mouse btn down"
 RDPT tvec,x,y,timeout
 if (returned with timeout)
   doDraw (Jackinthebox)
 else
   rem must have a button press
   check whether one of the guys was hit
 endif
endrep

That is: Your program will run fast and smooth if you stay in the rdpt call as 
long as possible and only return from there when something you need to act upon 
(either timeout or mouse button press/release) happens. This needs some 
creative twiddling of tvec and obviously a specific pointer sprite.

Hope this helps,
Tobias
_______________________________________________
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm

Reply via email to