Author Topic: using COLLISSION with pre drawn images  (Read 324 times)

0 Members and 1 Guest are viewing this topic.

Offline flexman

  • Windows user
  • *
  • Posts: 2
  • Activity:
    0%
  • Reputation: 0
  • With us since: 07/01/2012
    Years
    • View Profile
using COLLISSION with pre drawn images
« on: January 07, 2012, 07:05 PM »
Hi!

I would like to create a basic game where you move an sprite that shouldn't collide.

I really would like to try the collission command.

How about if I pre-draw an image and then load it? Will there be any problem with the background color? How should I specify the color that won't be any collission? Is there any programme for the PC I can draw images with that I can load in C128 basic?

Thanks,
Flex

Offline Hydrophilic

  • 128D user
  • *******
  • Posts: 1214
  • Age: 41
  • Location: Earth... still!
  • Activity:
    0%
  • Reputation: 232
  • Gender: Male
  • With us since: 25/01/2007
    YearsYearsYearsYearsYearsYears
    • View Profile
    • H2Obsesson
Re: using COLLISSION with pre drawn images
« Reply #1 on: January 09, 2012, 07:12 AM »
All of the non-transparent pixels in a sprite can cause a collision.  If you use the sprite on top of the text screen or hi-res bitmap then any pixels that touch will cause a collision.
 
But if you use a sprite on top of a multi-color bitmap, then only bitmap colors 2 and 3 will cause a collision.  Bitmap colors 0 and 1 are considered 'background' and will not cause a collision.
 
The easiest way for me is to create sprites using SPRDEF then save them to disk with a command
Code: [Select]
BSAVE"SPRITES",B0,P3584 TO P4096

To load them back just use
Code: [Select]
BLOAD"SPRITES",B0
You can add ",P3584" to specify the start address but you don't need to if you saved it like the example above (which writes the start address into the file header).
 
There are several editors available for the PC, but I haven't used any of them (old school baby).  The most recent that comes to mind is CBM .prg Studio.  This lets you create sprites, charsets, and even write programs and test them on your PC.  I don't know how difficult it would be to take a sprite from that and load into your own program, but it shouldn't be too difficult.
 
 
I'm kupo for kupo nuts!

Offline flexman

  • Windows user
  • *
  • Posts: 2
  • Activity:
    0%
  • Reputation: 0
  • With us since: 07/01/2012
    Years
    • View Profile
Re: using COLLISSION with pre drawn images
« Reply #2 on: January 09, 2012, 10:38 AM »
That sounds great! What does it mean, Colors 0-3? Do I only have 4 colors, or a range of 4 colors?

So pictures are 100% compatible to C64? That means I just need any C64 image drawer and can load this into a C128 game and use it with the sprite-collission there?

Offline Hydrophilic

  • 128D user
  • *******
  • Posts: 1214
  • Age: 41
  • Location: Earth... still!
  • Activity:
    0%
  • Reputation: 232
  • Gender: Male
  • With us since: 25/01/2007
    YearsYearsYearsYearsYearsYears
    • View Profile
    • H2Obsesson
Re: using COLLISSION with pre drawn images
« Reply #3 on: January 09, 2012, 03:06 PM »
As long as you are using the 40-column screen (and since you talk about sprites you must use the 40-column) then yes the bitmaps, character sets and sprites are directly compatible between the C64 and C128.  The only difference is the C128 gives you more freedom where you can place graphics in memory (the C64 forces ROM in certain VIC Banks, but you can choose freely with C128).
 
If you make a bitmap in multi-color mode then each pixel can be a value 0, 1, 2, or 3.  Within each 4x8 pixel area you can assign any of the 16 colors to those 4 values.  So in each small 4x8 area (the size of a text character) you can have only 4 colors, but because there are many such areas (1000 to be exact) you can use all 16 colors if you want.  The important thing to remember with multi-color bitmap is that only values 2 and 3 will cause a collision with sprites.
 
You should play around with BASIC GRAPHIC commands like DRAW and CIRCLE.  Try drawing some things on a multicolor bitmap (using different values like 1, 2, and 3) then see how they work when you turn on a SPRITE and use COLLISION.  There are few sample programs in the C128 System Guide and the C128 Programer's Reference Guide.  Another book with a lot of BASIC GRAPHIC programs (but not all) is 35 Amazing Games for Your C128.  You should be to find all of these books on bombjack.
I'm kupo for kupo nuts!

 



Back to top