|
Post by theelf on Mar 12, 2010 11:45:07 GMT -5
Hi, i have some questions whitout answer 1) if i made a scroll, how i can slowdown if is too fast? for example If i need to slowdown i use But the movement is choppy, not fluid. if i use " waitraster 224 " for example instead sleep 1, i get a better scroll, but fast, and if i mix waitraster and sleep 1, i get a better scroll than sleep 3 and right speed, but is a little choppy too... "This is the best i can... anyone have a better idea?" 2)Second question.. any way that the scroll function not affect the ShiftSprite command? if i have a sprite moving from up to down, in a increment of 1 ShiftSprite hero,0, 1 if i scroll UP, the sprite freeze (+1 -1 ;D) and if i scroll down, the sprite run double fast (+1 +1)... any solution? Thanxs!
|
|
|
Post by TheMVRules on Mar 12, 2010 11:48:18 GMT -5
(Untested) Put your scroll routine at vertical blank or use valt command. That might work.
|
|
|
Post by theelf on Mar 12, 2010 12:02:29 GMT -5
How to do you make this?
The help about valt is not very clear about how to use it
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Mar 12, 2010 12:07:30 GMT -5
theelf1 - There's no way to make movement of 1 pixel per 2 frames look less choppy. Unlike modern rendering engines ( using floating points ) where pixels are interpolated in real-time when they don't align precisely with the raster, the Megadrive / Genesis can only display tiles / sprites at one of 512x512 positions of the VDP. 2 - The scroll command does not influence the position of sprites .. you must be doing something wrong
|
|
|
Post by TheMVRules on Mar 12, 2010 12:07:32 GMT -5
It's the same as SLEEP 1,TVBLANK or SLEEP2 1,TVBLANK. Simple: VDP is idle at verticle blank so you can scroll without ugly effects.
2: "The Scroll command does not scroll sprites along with the background plane. Sprite will have to be shifted manually, if desired." from from the Holy bible: the documentation
|
|
|
Post by theelf on Mar 12, 2010 12:23:35 GMT -5
Great!! first question resolved!!! this is the solution of my problem!! THANXS
Is not smoth as waitraster 224, but it works a lot better than sleep 2 alone...
The problem of scroll, is i put the shiftsprite command in the same loop of scroll, the scroll function scroll sprites too, besides documentation.
maybe my code is bad
In this case, the scroll function scroll the enemigo sprite too
|
|
|
Post by TheMVRules on Mar 12, 2010 12:33:18 GMT -5
it should not Try put your joypad detection code to the vblank event. Most likely that won't work either... In that case it's a BasiEgaXorz bug. Other option: l33ch the scroll code from Turbo Cars. Maybe it will work then.
|
|
|
Post by theelf on Mar 12, 2010 12:48:05 GMT -5
Sorry, where is the Turbo Cars example? i dont find in the examples or forum
|
|
|
Post by TheMVRules on Mar 12, 2010 12:50:36 GMT -5
' Turbo Cars! ' By DevSter ' BasiEgaXorz 0.26 test program (2/12/2006)
high_score& = 0 reset_game: ' Reset screen freeallsprites scroll2 UP, 0 pallette &h00E0, 0, 0 pallette &h0000, 0, 1 settextplane SCROLL_A cls settextplane SCROLL_B cls ' Intro screen print "Devster's Turbo Cars!" print "Press START now!" print print print "High Score: "; high_score& waitpadup while (joypad().7 = 0) for a=0 to 500: next b++ randomize b wend waitpadup cls
' Road pallette colors pallette &h0AAA, 0, 0 pallette &h00E0, 0, 1
' Car pallette colors pallette &h000E, 1, 1 ' Text pallette colors pallette &h0A00, 2, 1 ' Obstacle pallette colors pallette &h0068, 3, 1 border_left = 10 border_right = 10 road_width = 20 top_location = 63
' option TEXTSTART, 0, 0 ' option TEXTWIDTH, 40 ' option TEXTHEIGHT, 28 settextplane SCROLL_A setgfxplane SCROLL_B setscrollplane SCROLL_B setscrollmode HSCROLL_OVERALL, VSCROLL_OVERALL
car_x = 128+(20*8)-4 car_y = 128+(28*8) car = addsprite(1, 1) propsprite car, &h0DB, 1 movesprite car, car_x, car_y
locate 1,1: ink 2 print "Score: 0"
for b=1 to 28 cur_location = 0 ink 0 for a=1 to border_left drawtile &h0DB, cur_location, top_location cur_location = cur_location + 1 next for a=1 to road_width drawtile &h020, cur_location, top_location cur_location = cur_location + 1 next for a=1 to border_right drawtile &h0DB, cur_location, top_location cur_location = cur_location + 1 next
for a=1 to 4 sleep 1, TVBLANK scroll DOWN, 2 next if top_location = 0 then top_location = 63 else top_location = top_location - 1 endif car_y = car_y - 4 movesprite car, car_x, car_y next locate 9,12: ink 2: print "Get Ready Dude!"
sleep 60*3 locate 9,12: ink 2: print " "
loops& = 0 score& = 0 last_obstacle = 100
while 1 ' Display Road cur_location = 0 ink 0 for a=1 to border_left drawtile &h0DB, cur_location, top_location cur_location = cur_location + 1 next for a=1 to road_width drawtile &h020, cur_location, top_location cur_location = cur_location + 1 next for a=1 to border_right drawtile &h0DB, cur_location, top_location cur_location = cur_location + 1 next ' Display Dots if rnd(2)=1 then ink 0 drawtile &h008, rnd(border_left-1), top_location drawtile &h008, border_left+road_width+1+rnd(border_right-1), top_location endif
' Insert Obstacles last_obstacle = last_obstacle - rnd(4) if (last_obstacle+4) <= 4 then ' Cheap negative number fix obstacle_x = border_left+rnd(road_width) ink 3 drawtile &h0DB, obstacle_x + 0, top_location drawtile &h0DB, obstacle_x + 1, top_location last_obstacle = 100 end if
' Insert Bonus if rnd(100)=50 then ink 1 drawtile asc("$"), border_left+1+rnd(road_width-3), top_location end if
' Scroll Road Up for a=1 to 2 sleep 1, TVBLANK scroll DOWN, 4 next if top_location = 0 then top_location = 63 else top_location = top_location - 1 endif ' Adjust Road Width decision = rnd(9) if decision<=2 then if border_left<>1 then border_left-- border_right++ endif elseif decision>=6 then if border_right<>1 then border_right-- border_left++ endif endif loops&++ if (loops& [and] &h000000FF) = 0 then road_width-- if border_left > border_right then border_right++ else border_left++ endif endif ' Collission Detection Calculation check_x1 = ((car_x [and] &hFFF8) - 128) >> 3 if (car_x [and] &h0007) = 0 then check_x2 = check_x1 else check_x2 = check_x1 + 1 endif check_y = top_location+15 if check_y > 63 then check_y=check_y-64 ' locate 10,10: print readtile(check_x1,check_y) tile_1 = readtile(check_x1,check_y) [and] &h07FF tile_2 = readtile(check_x2,check_y) [and] &h07FF if tile_1=&h0DB [or] tile_2=&h0DB then locate 10,16: ink 2 print "Crashed!" if score& > high_score& then sleep 60*3 locate 12,16: ink 2 print "New High Score!" high_score& = score& endif waitpadup while (joypad().7 = 0) for a=0 to 500: next b++ randomize b wend goto reset_game elseif tile_1=asc("$") [or] tile_2=asc("$") then score& = score& + 100000 if tile_1=asc("$") then drawtile &h020, check_x1, check_y if tile_2=asc("$") then drawtile &h020, check_x2, check_y endif ' Score Management locate 1,1: ink 2 print "Score: "; score& score& = score& + ((40-road_width)*10)
' Player Joypad Inputs joy = joypad() if joy.2 then ' left direction button car_x = car_x - 3 endif if joy.3 then ' right direction button car_x = car_x + 3 endif movesprite car, car_x, car_y wend
|
|
|
Post by theelf on Mar 12, 2010 12:56:25 GMT -5
Thanxs! funny game! i check the code this night... looks like maybe i can found a solution to the second problem..
|
|
|
Post by Tom Maneiro on Mar 20, 2010 2:48:15 GMT -5
Talking about scroll, i've noticed a interesting and weird thing: I've implemented scrolling on latest CrazyBus 2.00 bus selector: it does scroll smoothly for me, but... 1) I'm doing some tile drawing "behind the scenes" (for switching pictures when scrolling), but if i use a SELECT CASE instead of a IF-ELSE, the scrolling will LAAAAAAAAAG! 2) The upper two rows on the screen seems to "skew" a bit when scrolling (at least as observed in Fusion...) Here is my code (comment translation left as an exercise for the reader): 'Desplazar en pantalla de seleccion declare sub scrollBus(dir as integer) 'Direcciones: 0 = atras, 1 = adelante
if dir = 1 then 'izquierda for z = 1 to 512 scroll left, 1 'Pausar cada 16 pixeles para no hacer tan volado 'el desplazamiento de paginas if z % 16 = 0 then sleep 1 endif 'BEX 1.37 BUG: SELECT CASE provoca que el desplazamiento se ahogue ' espantosamente tras dibujar la foto del autobus (!!!) ' Con IF/ELSE no existe tal perdida de rendimiento if z = 216 then 'select case z ' case 216 '-216: foto showbus busID, 1 ' exit case elseif z = 312 then ' case 312 '-312: logo showbus busID, 0 ' exit case 'end select endif next z else if dir = 0 then 'derecha for z = 1 to 512 scroll right, 1 'idem idem... if z % 16 = 0 then sleep 1 endif if z = 144 then 'select case z ' case 144 '+144: logo showbus busID, 0 ' exit case elseif z = 296 then ' case 296 '+296: foto showbus busID, 1 ' exit case 'end select endif next z endif end sub
theelf: Notice that i perform a sleep each 16 pixels, for controlling the speed. Looks smooth for me
|
|
|
Post by Mairtrus on Mar 20, 2010 9:41:49 GMT -5
Maybe the slowdown is caused because you are using Exit Case, and it's Exit Select ?
|
|
|
Post by theelf on Mar 20, 2010 9:52:18 GMT -5
Great, tomorrow i have time, and I will try this trick! Thanxs
I've seen the same problem in several scroll I did.
I think using TVBLANK to sleep, or waitraster 224 in place of sleep does not happen...
|
|
|
Post by Mairtrus on Mar 20, 2010 10:15:40 GMT -5
I've seen the same problem in several scroll I did. I think using TVBLANK to sleep, or waitraster 224 in place of sleep does not happen... That's because you are scrolling during the period where the VDP is drawing the screen. This cause an unwanted raster effect. Both TheElf's solutions works, but I prefer to put it into the verticle blank interruption's subroutine.
|
|
|
Post by Tom Maneiro on Mar 20, 2010 12:42:48 GMT -5
Well, i'm already using the VBI subroutine for doing the game music, but anyway, i will give these alternatives a good try Anyway, the "skewing" is not annoying for me. Depending on the game genre, it may be actually the desired effect
|
|