Posted: Tue Dec 20, 2011 3:21 pm Post subject: RE:Need Help with Collision and Screen Flickering
Or, you could do things the obvious way:
Turing:
if chars(' ')then
Nablo
Posted: Tue Dec 20, 2011 3:42 pm Post subject: Re: Need Help with Collision and Screen Flickering
One thing I noticed is that I need the ball to be going in an set motion (which would require a loop) and I also need the character to be moving at the same time. I did this before using a process. Now that I eliminated using a process due to the "one view update" rule, how would I achieve the same effect?
Tony
Posted: Tue Dec 20, 2011 3:45 pm Post subject: RE:Need Help with Collision and Screen Flickering
move the ball and the character within the same single loop.
Posted: Tue Dec 20, 2011 3:50 pm Post subject: RE:Need Help with Collision and Screen Flickering
This is a common problem, so consider searching the forums for more details. The skeleton, however, looks like this:
code:
loop
clear screen
move everything a little
draw everything in its current position
View.Update
Time.DelaySinceLast ( 50 )
end loop
That will lock your game to a maximum of 20 frames per second (pushing it, for Turing in most cases), and will let you move multiple things at the same time. Move everything a small amount, but consistent with its speed: each step is 50 milliseconds. A human walking moves about 1m/s, so they would move 1 * 0.05 = 5cm during that time; a car on a highway travels something like 30m/s, so it would move 30 * 0.05 = 1.5m in that time.
Nablo
Posted: Tue Dec 20, 2011 5:34 pm Post subject: Re: Need Help with Collision and Screen Flickering
Thanks guys! With your help and patience I managed to solve the flickering problem, but now because of that a new problem arose -> the weird update problem. Try running my program and see what I mean... I know which part of the program is causing the problem but I don't know how it is causing the problem.
Here is my refurbished program with the problematic section bolded:
Turing:
% Declare Variables
var CXBLSSBbody, CYBLSSBbody, CXTRSSBbody, CYTRSSBbody, CXSBarm, CYSBarm, CXRSBarm, CYRSBarm, CXSBfan, CYSBfan, CXRSBfan :int var CYRSBfan, CXBLSSBhead, CYBLSSBhead, CXTRSSBhead, CYTRSSBhead, CXBLSSBleftleg, CYBLSSBleftleg, CXTRSSBleftleg :int var CYTRSSBleftleg, CXBLSSBrightleg, CYBLSSBrightleg, CXTRSSrightleg, CYTRSSBrightleg, CXBLSSBleftshoe, CYBLSSBleftshoe :int var CXTRSSBleftshoe, CYTRSSBleftshoe, CXBLSSBrightshoe, CYBLSSBrightshoe, CXTRSSrightshoe, CYTRSSBrightshoe :int var CXSBlefteye, CYSBlefteye, CXRSBlefteye, CYRSBlefteye, CXSBrighteye, CYSBrighteye, CXRSBrighteye, CYRSBrighteye :int var CXBLP, CYBLP, CXRSBbiglandingpad, CYRBLP, CXSLP, CYSLP, CXRSLP, CYRSLP, CXESbody, CYESbody, CXRESbody, CYRESbody :int var CX1ESspiketopleft, CX2ESspiketopleft, XY1ESspiketopleft, CY2spiketopleft, CX1ESspiketopright, CX2ESspiketopright :int var XY1ESspiketopright, CY2spiketopright, CX1ESspikebottomleft, CX2ESspikebottomleft, XY1ESspikebottomleft :int var CY2spikebottomleft, CX1ESspikebottomright, CX2ESspikebottomright, XY1ESspikebottomright, CY2spikebottomright :int var CX1ESspikeleftleft, CX2ESspikeleftleft, XY1ESspikeleftleft, CY2spikeleftleft, CX1ESspikeleftright :int var CX2ESspikeleftright, XY1ESspikeleftright, CY2spikeleftright, CX1ESspikerightleft, CX2ESspikerightleft :int var XY1ESspikerightleft, CY2spikerightleft, CX1ESspikerightright, CX2ESspikerightright, XY1ESspikerightright :int var CY2spikerightright, CXBLSP, CYBLSP, CXTRSP, CYTRSP, CXB, CYB, CXRB, CYRB, CXBLSBH, CYBLSBH, CXTRSBH, CYTRSBH :int var life :int var speed :int:=1 var counter :int:=0 var chars :arraycharofboolean
Font.Draw("Play",50, maxy - 150, arialb, c) if button =0and x > 50and x < 130and y > 320and y < 356then
c :=94 elsif
button =1and x > 50and x < 130and y > 320and y < 356then
if CXRSBarm >= maxxand CXSBarm <= 0and CYRSBarm >= maxyand CYSBarm <= 0then
life := life - 1
elsif CXTRSSBbody >= maxxand CXBLSSBbody <= 0and CYBLSSBbody >= maxyand CYTRSSBbody <= 0then
life := life - 1
elsif CXTRSSBhead >= maxxand CXBLSSBhead <= 0and CYBLSSBhead >= maxyand CYTRSSBhead <= 0then
life := life - 1
elsif CXTRSSBleftleg >= maxxand CXBLSSBleftleg <= 0and CYBLSSBleftleg >= maxyand CYTRSSBleftleg <= 0then
life := life - 1
elsif CXTRSSrightleg >= maxxand CXBLSSBrightleg <= 0and CYBLSSBrightleg >= maxyand CYTRSSBrightleg <= 0then
life := life - 1
elsif CXTRSSBleftshoe >= maxxand CXBLSSBleftshoe <= 0and CYBLSSBleftshoe >= maxyand CYTRSSBleftshoe <= 0then
life := life - 1
elsif CXTRSSrightshoe >= maxxand CXBLSSBrightshoe <= 0and CYBLSSBrightshoe >= maxyand CYTRSSBrightshoe <= 0then
life := life - 1
endif
% Colission with Portal
if CXRSBarm >= CXBLSBH and CXSBarm <= CXTRSBH and CYRSBarm >= CYBLSBH and CYSBarm <= CYTRSBH then
life := life - 1
elsif CXTRSSBbody >= CXBLSBH and CXBLSSBbody <= CXTRSBH and CYBLSSBbody >= CYBLSBH and CYTRSSBbody <= CYTRSBH then
life := life - 1
elsif CXTRSSBhead >= CXBLSBH and CXBLSSBhead <= CXTRSBH and CYBLSSBhead >= CYBLSBH and CYTRSSBhead <= CYTRSBH then
life := life - 1
elsif CXTRSSBleftleg >= CXBLSBH and CXBLSSBleftleg <= CXTRSBH and CYBLSSBleftleg >= CYBLSBH and CYTRSSBleftleg <= CYTRSBH then
life := life - 1
elsif CXTRSSrightleg >= CXBLSBH and CXBLSSBrightleg <= CXTRSBH and CYBLSSBrightleg >= CYBLSBH and CYTRSSBrightleg <= CYTRSBH then
life := life - 1
elsif CXTRSSBleftshoe >= CXBLSBH and CXBLSSBleftshoe <= CXTRSBH and CYBLSSBleftshoe >= CYBLSBH and CYTRSSBleftshoe <= CYTRSBH then
life := life - 1
elsif CXTRSSrightshoe >= CXBLSBH and CXBLSSBrightshoe <= CXTRSBH and CYBLSSBrightshoe >= CYBLSBH and CYTRSSBrightshoe <= CYTRSBH then
life := life - 1
/*elsif x2 >= CXBLSBH and x1 <= CXTRSBH and y2 >= CYBLSBH and y1 <= CYTRSBH then
life := life - 1
elsif x2 >= CXBLSBH and x1 <= CXTRSBH and y2 >= CYBLSBH and y1 <= CYTRSBH then
life := life - 1
elsif x2 >= CXBLSBH and x1 <= CXTRSBH and y2 >= CYBLSBH and y1 <= CYTRSBH then
life := life - 1*/ endif
endif endloop
var r, axle :int var h, k, x1 :real var xchange :int:=20 const pi :=22 / 7
r :=640
k :=18
x1 := r
axle :=300 loop
x1 := x1 + xchange
if x =200then
xchange := xchange * -1 endif
if x =0then
xchange := xchange * -1 endif
h := r *cos(k * x1) + axle
drawfilloval(round(x1),round(h),25, 25, black) put h
%View.Update delay(100) cls endloop