News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_Fabrizio Radica

Sprites on Basic

Started by Fabrizio Radica, 18:16, 16 October 18

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Fabrizio Radica

Hi,
I've a question.
i've made this - unoptimized code -, for make a "big" sprite maked with AMSprite, but doesn't works.
Is displayed incorrectly.
Why? Can you help me?
Tnx :)

10 cls: mode 0
20 posx=posx+1:posy=1:restore 5000
100 for y=1 to 8
120 for x=1 to 4
200 read a:poke &c000+(x+posx)+(y+posy)*80,a
220 next x
300 next y

500 goto 500

5000 REM sprite
5010 DATA 0,68,136,0
5020 DATA 0,68,136,0
5030 DATA 145,48,48,98
5040 DATA 0,153,102,0
5050 DATA 0,153,102,0
5060 DATA 16,0,0,32
5070 DATA 136,0,0,68
5080 DATA 128,0,0,64




PuzCPC




Hi,


Try this


200 read a:poke &c000+(x+posx)+(y+posy)*&800,a

Fabrizio Radica

Hi!,
works fine!
please, can you explain me why? :)
tnx :)

Quote from: PuzCPC on 18:31, 16 October 18

Hi,


Try this


200 read a:poke &c000+(x+posx)+(y+posy)*&800,a

HAL6128

#3
This is the way how the screen memory is organized. The next line on screen doesn't start after 80 (&50) instead after &800:e.g. first line &C000, second line &C800 (not &C050 which is the 9th line). Pretty weird, isn't it? :)
By the way: you can create a faster sprite in Basic with symbol definition and transparency too.
...proudly supported Schnapps Demo, Pentomino and NQ-Music-Disc with GFX

mr_lou

Quote from: HAL 6128 on 21:18, 16 October 18
By the way: you can create a faster sprite in Basic with symbol definition and transparency too.

Yea, poking to screen memory from BASIC really isn't the way to go. It is extremely slow.


You should either get some RSX sprite routines, or else use SYMBOL to define sprites and simply PRINT to display them.

Fabrizio Radica

I've used symbol definition (and transparency) on this but i wanted to try new solutions for big sprites or big tiles.
Anyway, next time i whould like to use ASM (but I do not know the z80 opcode at the moment) :)

So, for big sprites (or tiles) recommend me to use two or more - symbol definition  -attached?tnx :)

https://www.youtube.com/watch?v=qhCgyKwt6JQ

Quote from: HAL 6128 on 21:18, 16 October 18This is the way how the screen memory is organized. The next line on screen doesn't start after 80 (&50) instead after &800:e.g. first line &C000, second line &C800 (not &C050 which is the 9th line). Pretty weird, isn't it? :)
By the way: you can create a faster sprite in Basic with symbol definition and transparency too.

mr_lou

For big sprites using SYMBOL, yes we would just use multiple characters. One good recent example of this is the BASIC game Coolbox. http://www.cpc-power.com/index.php?page=detail&num=13102
You might be interested in looking at the source of that game. :-)

There are a few options. If we take a 4-character example, the most basic ones would look like this:

sprite1$ = "ABCD" ' Long 4x1 character sprite
sprite2$ = "AB̉←←↓CD" ' Square 2x2 character sprite
sprite3$ = "A←↓B←↓C←↓D" ' Long 1x4 character sprite

Those are single coloured ones.
The arrows are control codes. There exists control codes that can change pen color and paper color and tell the CPC to print the character on top of another. These control codes are listed in the back of the CPC instruction manual. (Chapter 9 in the CPC464 instruction manual). I bet you can also find them here on the CPCwiki.

HAL6128

Yeah, it's like mr_lou said... you can combine 8x8 characters to a bigger and colored sprite and it's even fast enough to have some joy. Keep on going with BASIC, it's fun! :)

I did two games attempt which were programmed completley in BASIC:
A Frogger conversion. The biggest sprite was a lorry with 3 characters together.

https://youtu.be/V3oEWzbJ8G8
And a Candy Crush conversion (not finished). The biggest sprite contains 4 colored characters.

https://youtu.be/CLWD8bjoM3w

Cheers
...proudly supported Schnapps Demo, Pentomino and NQ-Music-Disc with GFX

ervin

HAL, those are *very* impressive!

Fabrizio Radica

...as we say in Italy: MINCHIA!!!  :P



Quote from: HAL 6128 on 19:23, 17 October 18Yeah, it's like mr_lou said... you can combine 8x8 characters to a bigger and colored sprite and it's even fast enough to have some joy. Keep on going with BASIC, it's fun! :)

I did two games attempt which were programmed completley in BASIC:
A Frogger conversion. The biggest sprite was a lorry with 3 characters together.

https://youtu.be/V3oEWzbJ8G8
And a Candy Crush conversion (not finished). The biggest sprite contains 4 colored characters.

https://youtu.be/CLWD8bjoM3w

Cheers

tjohnson

Quote from: Fabrizio Radica on 07:21, 18 October 18
...as we say in Italy: MINCHIA!!!  :P
are you able to share any code?  I tried to get transparency working but couldn't

AMSDOS

Don't know if I could interest anyone in a Huge Chunky Maze with Hazard within?
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS

Quote from: tjohnson on 09:29, 18 October 18
are you able to share any code?  I tried to get transparency working but couldn't


I have a number of examples on the Programming Tread I've built over the years, but this link shows a simple example of using Transparency. The other examples I've included around that try to condense the graphical data so it could be used for something like a 10-Liner.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Dabz

Dont forget Sean McManus's excellent sprite tools:-


https://www.sean.co.uk/books/amstrad/cpcdownload.shtm


Dabz

AMSDOS

Quote from: Dabz on 07:20, 01 November 18
Dont forget Sean McManus's excellent sprite tools:-


https://www.sean.co.uk/books/amstrad/cpcdownload.shtm


Dabz


I seems to be the best approach for handing Sprites of various lengths of sizes and works on all systems. It can really transform a game as I was able to demonstrate earlier with early versions of my game and the final result after Easi-Sprite Driver was implemented. The horror with that was both versions were still being compiled.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Powered by SMFPacks Menu Editor Mod