Page 2 of 2

Re: How to erase without flicker?

Posted: Fri May 11, 2018 11:25 pm
by llewelyn
Thanks Robin, yes I am anticipating eventually moving by pixels but first things first. I need to cut and paste all these useful pieces of programming info, thats the trouble with message bases, locating the hidden gems!

Re: How to erase without flicker?

Posted: Sat May 12, 2018 6:23 am
by Nomad
Another reason to be more careful about the use of CLS. You are giving up control of how you refresh the screen. If at some point you want to have more elements on the screen odds are you don't want to re-draw them every time you move the player object. CLS throws everything in the bin. The overwrite techniques give you flexibility/options that you wouldn't otherwise have.

A little bit of ghosting I wouldn't sweat as long as it didn't impact gameplay. You got to think about how much time/effort its going to take to get something perfect and if it is possible/worth it. Depends how you are wired I guess.

Re: How to erase without flicker?

Posted: Sat May 12, 2018 1:43 pm
by llewelyn
You're quite right Nomad and I think R-Tape said much the same thing. I only used CLS in the first iteration as a quick and dirty, easy way to get the job done. Also I have since discovered that chasing the ghosts isnt worth it, eventually hopefully no one will notice if theres other things going on to take their mind off minor glitches. Sometimes the ghosts actually work in my favour as can be seen if this is run:-


10 CLS
20 PRINT AT 10,10; "Press s to STOP"
30 FOR x=1 TO 30 STEP 1
40 PRINT AT 1,x;" AB "
50 PRINT AT 2,x;" CD "
60 PAUSE 5
70 IF x=30 THEN GOTO 10

Re: How to erase without flicker?

Posted: Sat May 12, 2018 3:26 pm
by dfzx
Well intentioned as they are, I don't think people trying to push you towards machine code or hacks that clear the previous position with a preceding space are quite what you're after.

Try to think clearly about what you want to do. I would suggest that this psuedo-code is roughly what you're after:

Code: Select all

new_x,new_y = 10,10
print sprite at new_x,new_y

  old_x,old_y = current sprite position
  decide where you want the sprite to move to
  new_x,new_y = newly decided sprite position
  print a space at old_x,old_y
  print the sprite at new_x,new_y
  loop back to loop:
So start the sprite character at 10,10, then decide where you want it to move to (based on user input or just your simple left-to-right loop for starters). That gives you a new x,y position. Then print a space over the top of the current character to remove it, then print the character in the new location.

Then go round again: note where the character currently is, decide where you want it, then print a space over it to remove it and print it again in its new place. Repeat.

Once you can see what this is doing, convert it to BASIC. :)

Re: How to erase without flicker?

Posted: Sat May 12, 2018 3:57 pm
by llewelyn
Nicely explained dfzx - thank you.

You are quite correct about the machine code aspect. I have tried and tried, read books, watched video instructions about it but the sad fact of the matter is that I cannot get my head around it and believe me I have tried!

Which is fine, I'm just a dabbler doing a spot of Basic problem solving for the enjoyment of it. I have no ambition to advance beyond Basic and its only because of its Basic that I remain so fond of the machine - emulator - I wish it was a genuine rubber key 48k Mk1 Speccy.

Re: How to erase without flicker?

Posted: Tue May 15, 2018 1:43 am
by llewelyn
Okay this is a development from the original moving blob. Nothing to write home about really although it took me 8 hours to work out the UDG's and then arrange them to get a moving - staying in one spot but the tracks move - Mk 1 tank! I hope to have it able to move according to keyboard input later, probably take me a couple more days.

Its a .SNA file that has to be downloaded and run in your emulator or machine of choice. ... 9323534450

Re: How to erase without flicker?

Posted: Tue May 15, 2018 6:52 am
by R-Tape
Nice wee (not so wee!) UDG tank.

Drawing the tank is a bit cumbersome though & it'll become a pain if you develop the idea.

I'd suggest storing the tank top and bottom as strings, then you can print with a lot less code.



Then to print the tank you can do this:


then you can move the tank by manipulating TY,TX.

Re: How to erase without flicker?

Posted: Tue May 15, 2018 11:06 am
by llewelyn
Thanks R-Tape! I'll give that a test to see how it works.

UDG design can be a real test of patience. What looks good on graph paper doesnt appear like that on screen because of its being so tiny you often have to exaggerate features enough to make them visible. Yet on graph paper it can look really awful, you can hardly make out what it is.

I used BASin to draw them and I wrote the print at code in BASin then saved it as a .sna and transferred it to Fuse which I find much easier to code with.

Before I develop the program I need to rethink the UDGs to get a better looking sprite. More detail and a bit of colour might help which means altering the placement within the character square. Trial and error takes forever.

Re: How to erase without flicker?

Posted: Wed Jun 13, 2018 11:20 am
by Joefish
Yep, you can also use arrays to store how the tank looks going in different directions. But remember that a string is already an array (of characters). So if you want an array with 2 different 'looks', 2 rows of UDGs, and each one 4 characters long, that's a 2x2x4 3-dimensional array.