Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Starting a fighting game
#31
Quote:I'd like to say thank you before I begin with my post. Wiz, your the best. I mean I can't believe you actually sat down and wrote code for me. Second I'd like to apoligize for not replying right away. Don't take it as insult. It turned out I had quite a few tests, and project due today. I've been trying very hard to get back to qb but simply didn't manage. So thank you all for understanding and don't take think your posts went to waste for my long silence at the forums.
No problem at all.
Quote:Sadly I didn't understand all of it. So I decided to number all the lines in your code wiz and try to ask very specific questions.
That's the best way. Good plan.

Quote:Line 3 - The Dim Statement

I know how the dim statement is used in arrays, and I thought before I had a general understanding of it. It has become aparent to me that I need further understanding in order to use properly all the time. The dim statement sets dimentions and in this case to (I assume) an array called sprite? What are the values for exactly, and how do they work?
The awkwardness here is partly due to the fact that the Basic language has no data type for a single byte. So a 16x16 image takes 256 bytes, but that's 128 integers... since an integer is two bytes. Now there's an extra two integers that store the height and width, and that's why the dimension is 0..129.

The other dimension is simply the number of the sprite. I'm illustrating for you the maximum possible number of sprites that can be stored in a single array.

So a single-dimensional array is like a long chain of values, whereas a multidimensional one is like a plane or a cube. In this case we have 253 sprites that each require 260 bytes to store them.
Quote:Line 7 - The OPEN Command

In a previous program, I used the OPEN command in order to load a .txt file and save information onto it. The normal way of using it I suppose. In this case I see the WORD binary and it's used to load an image. I have a few questions here.
There's no 'normal' way to access data files. Text mode is more appropriate in some cases, and Binary is in others. Basically Text access pampers you with lots of help like the ability to read a single line easily and to break up a string of values separated by commas, etc.

Binary access lets you jump to an exact byte in the file and read x number of bytes into whatever variable you want. QB only allows me to read however many bytes are in the variable. Pascal has the more powerful BlockRead command that let me copy as many as I wanted at once (exactly 258 bytes), so it doesn't have the loop.
Quote:Can you use the OPEN command to load in any graphic or other file format? For example a gif, jpg, or an avi?
Ultimately, yes, but it's not a single-statement deal. I'm not familar with those formats, but I know AVI is an absolute nightmare to decode because it incorporates other formats into it.

Quote:Line 11 - I guess I'm just dumb

Well I'm sorry but I really don't understand this part. I know what LOF(1) is. Your taking the size of the image loaded and subtracting 768. I don't get it. Why do you subtract 768?
768 is the length of the palette. I'll get into that more farther down. I could have simply hardcoded a number of sprites for the loop to load up, but it's more elegant to have a loop that simply loads however many are there. So I subtract the palette info, and then divide the remaining number of bytes by 258, the 'bytes-per-sprite', and that gives me the number of sprites in the file.

Quote:Line 13-17 - I don't understand the logic here

Next you've launched a for loop which I assume takes the sprites and loads them into the sprite array, am I right? Simple enough I understand the Get command, is used to store everything into that little array you dimentionalized earlier and Put of coarse displays the sprite saved in umm sprite(num1 ,num2 ). Once again what does the num1, and num2 stand for?

Next your setting, according to your comments, the width and height. I don't quite follow this logic here. If it should be 16x16. Then why would you set the first one to 128 (16*8). Now besides that point I don't quite understand this. Your setting all 0s to be the width, and all heights to be 1s. Obviously it works becuase the program ran perfectly and your a genious but I miss the logic here. So your setting things to certain numbers, and playing around with width and height in a way I really don't understand.
I don't actually get it either. I got so frustrated playing with those values that I eventually just used a GET statement to cap a blank 16x16 block and then examined the first couple bytes in it. Those were the values there, so clearly if your sprites are 8x8, those lines will need to look like this:
Code:
sprite%(0, ctr) = 64
sprite%(1, ctr) = 8
Quote:Line 20-24 - The important loop I assume

Before I go on, I didn't get the translation for your variables. What does ctr stand for and what does word stand for and imply.

Now umm I assume this loop does the importand work becuase it actually stores the sprites. I'll keep this short and simple, I don't understand the proccess.

I'm not going to ask the same question on the PUT command which is further down because it will probably be answered in part with the rest of them.
As stated above, if we had a BlockRead command, this would all be a lot more intuitive. As it is, the goal of the exercise is to simply transfer the 256 bytes of raw for each sprite from the file into memory.

ctr -> the number of the sprite we're currently loading in.
word -> the current 'pair' of bytes we're copying.

In other languages, 'word' is the term for a two-byte unsigned variable. All variables in QB are signed... another gripe.

Quote:Now I've never played around with pallets before. Ever. I need someone to explain to me how the proccess works. What are palletes used for? How are they implented? And how the code in the end works?
Basically there are two ways to represent the colours in an image. The original way that programmers came up with was the indexed palette. The way it's done nowadays is by non-indexed palette. A non-indexed palette means that for every pixel on the screen, there is a red, green, and blue value stored in your memory. (prolly on the gfx card, since it ends up being like 3MBs)

But the way Indexed colour works is that instead of having RGB values for every pixel, you simply have a 'colour number', and then you have a big list elsewhere that defines for each colour number (or index) what the Red, Green, Blue intensities are.

So the palette is 768 bytes long because there's 3 bytes for each colour: R G B. 3 * 256 = 768.

Now again, the way I load it in is awkward because I need to load in a pair of bytes, grab the first little bit, backstep one, grab the next pair... etc... That's what the AND 63 does. Say we load two bytes out of the file and they look like this:

10110100 01000110

We're only interested in the first byte, and moreover, only in the 0-63 part, since that's the range for the RGB values. So we do a binary AND operation, with 63 being the other value:

10110100 01000110 AND
11111110 00000000 =
10110100 00000000

What happens is that the AND operation neatly clips off the other byte and leaves up with the value we need for our Palette statement.

As far as the syntax for that, look it up in the help, or better yet, use the OUT formula... Run a search for an old thread about it.

Quote:I have to apolize for this extremly long post and my stupidity in the subject. I'm simply not aware and a little in experienced. I'm more than willing to learn. I want to learn. I need to learn. But someone please talk, for me to listen.
No problem at all. I enjoy it.
Quote:I love this community and when I one day move onto the next language I so wish this community follows.
Heh. Not likely. But there's always the 'General Programming' board.
Reply


Messages In This Thread
Starting a fighting game - by Kofman - 04-21-2003, 06:00 AM
Starting a fighting game - by LooseCaboose - 04-21-2003, 07:54 AM
Starting a fighting game - by Kofman - 04-21-2003, 07:35 PM
Starting a fighting game - by na_th_an - 04-21-2003, 10:37 PM
Starting a fighting game - by wizardlife - 04-22-2003, 01:39 AM
Starting a fighting game - by na_th_an - 04-22-2003, 02:28 AM
Starting a fighting game - by Kofman - 04-22-2003, 02:29 AM
Starting a fighting game - by na_th_an - 04-22-2003, 02:45 AM
Starting a fighting game - by Kofman - 04-22-2003, 02:52 AM
Starting a fighting game - by na_th_an - 04-22-2003, 02:55 AM
Starting a fighting game - by Kofman - 04-22-2003, 03:01 AM
Starting a fighting game - by wizardlife - 04-22-2003, 03:30 AM
Starting a fighting game - by Kofman - 04-22-2003, 03:33 AM
Starting a fighting game - by na_th_an - 04-22-2003, 05:40 AM
Starting a fighting game - by Kofman - 04-22-2003, 06:57 AM
Starting a fighting game - by wizardlife - 04-22-2003, 08:05 AM
Starting a fighting game - by Kofman - 04-23-2003, 03:56 AM
Starting a fighting game - by Kofman - 04-23-2003, 04:17 AM
Starting a fighting game - by Kofman - 04-23-2003, 04:23 AM
Starting a fighting game - by wizardlife - 04-23-2003, 06:11 AM
Starting a fighting game - by Kofman - 04-23-2003, 06:27 AM
Starting a fighting game - by wizardlife - 04-23-2003, 06:38 AM
Starting a fighting game - by wizardlife - 04-23-2003, 06:39 AM
Starting a fighting game - by Kofman - 04-23-2003, 07:32 AM
Starting a fighting game - by wizardlife - 04-23-2003, 08:16 AM
Starting a fighting game - by Rokkuman - 04-23-2003, 08:07 PM
Starting a fighting game - by wizardlife - 04-23-2003, 09:00 PM
Starting a fighting game - by Kofman - 04-26-2003, 09:05 AM
Starting a fighting game - by Kofman - 04-26-2003, 09:06 AM
Starting a fighting game - by wizardlife - 04-26-2003, 09:51 AM
Starting a fighting game - by Kofman - 04-26-2003, 07:41 PM
Starting a fighting game - by wizardlife - 04-26-2003, 09:33 PM
Starting a fighting game - by Kofman - 04-26-2003, 09:52 PM
Starting a fighting game - by Kofman - 05-08-2003, 10:11 PM
Starting a fighting game - by Kofman - 05-09-2003, 12:26 AM
Starting a fighting game - by wizardlife - 05-09-2003, 04:20 AM
Starting a fighting game - by Kofman - 05-09-2003, 04:37 AM
Starting a fighting game - by Kofman - 05-09-2003, 05:27 AM
Starting a fighting game - by na_th_an - 05-09-2003, 06:11 AM
Starting a fighting game - by Kofman - 05-09-2003, 06:44 AM
Starting a fighting game - by Kofman - 05-09-2003, 06:48 AM
Starting a fighting game - by wizardlife - 05-09-2003, 06:56 AM
Starting a fighting game - by Kofman - 05-09-2003, 09:10 AM
Starting a fighting game - by wizardlife - 05-10-2003, 12:01 AM
Starting a fighting game - by wizardlife - 05-10-2003, 12:20 AM
Starting a fighting game - by Kofman - 05-10-2003, 06:29 AM
Fascinating... - by Glenn - 05-10-2003, 06:53 AM
Re: Fascinating... - by wizardlife - 05-10-2003, 06:36 PM
Starting a fighting game - by Kofman - 05-11-2003, 12:17 AM
Starting a fighting game - by Kofman - 05-11-2003, 12:30 AM
Starting a fighting game - by wizardlife - 05-11-2003, 01:32 AM
Starting a fighting game - by Kofman - 05-11-2003, 02:52 AM
Starting a fighting game - by wizardlife - 05-11-2003, 03:52 AM
Starting a fighting game - by Kofman - 05-11-2003, 04:15 AM
Starting a fighting game - by Kofman - 05-11-2003, 04:24 AM
Starting a fighting game - by Kofman - 05-11-2003, 04:36 AM
How do I begin an animation engine - by Kofman - 05-11-2003, 04:41 AM
Starting a fighting game - by Kofman - 05-13-2003, 03:32 AM
Starting a fighting game - by na_th_an - 05-13-2003, 03:43 AM
Starting a fighting game - by Kofman - 05-13-2003, 04:57 AM
Possible answer... - by Glenn - 05-13-2003, 06:52 AM
Starting a fighting game - by na_th_an - 05-13-2003, 07:25 AM
Starting a fighting game - by wizardlife - 05-13-2003, 07:54 AM
Starting a fighting game - by na_th_an - 05-13-2003, 08:02 AM
Starting a fighting game - by wizardlife - 05-13-2003, 08:16 AM
Starting a fighting game - by Kofman - 05-14-2003, 05:35 AM
Did you see where... - by Glenn - 05-14-2003, 05:39 AM
Starting a fighting game - by na_th_an - 05-14-2003, 06:26 AM
I didn't see your other question... - by Glenn - 05-14-2003, 08:21 AM
Starting a fighting game - by Kofman - 05-19-2003, 02:05 AM
Starting a fighting game - by na_th_an - 05-19-2003, 04:53 AM
Starting a fighting game - by Kofman - 05-19-2003, 05:45 AM
Starting a fighting game - by na_th_an - 05-19-2003, 06:24 AM
Starting a fighting game - by toonski84 - 05-19-2003, 09:43 AM
Starting a fighting game - by na_th_an - 05-19-2003, 04:36 PM
Starting a fighting game - by Kofman - 05-19-2003, 05:10 PM
Starting a fighting game - by wizardlife - 05-20-2003, 04:05 AM
Starting a fighting game - by na_th_an - 05-20-2003, 06:17 AM
Starting a fighting game - by Kofman - 05-22-2003, 01:47 AM
Starting a fighting game - by Kofman - 05-22-2003, 03:35 AM
Starting a fighting game - by Kofman - 05-22-2003, 05:13 AM
Starting a fighting game - by Kofman - 05-22-2003, 06:07 AM
Starting a fighting game - by wizardlife - 05-22-2003, 06:41 AM
Starting a fighting game - by na_th_an - 05-22-2003, 07:06 AM
Starting a fighting game - by Kofman - 05-23-2003, 02:37 AM
Starting a fighting game - by Ninkazu - 05-23-2003, 02:40 AM
Starting a fighting game - by Kofman - 05-23-2003, 05:38 AM
Starting a fighting game - by Kofman - 05-25-2003, 12:27 AM
Starting a fighting game - by Kofman - 05-25-2003, 12:30 AM
Starting a fighting game - by na_th_an - 05-25-2003, 12:37 AM
Starting a fighting game - by Kofman - 05-25-2003, 12:57 AM
Starting a fighting game - by Kofman - 05-25-2003, 12:59 AM
Memory in real mode is accessed... - by Glenn - 05-25-2003, 03:48 AM
Starting a fighting game - by na_th_an - 05-25-2003, 04:59 AM
Starting a fighting game - by Kofman - 05-25-2003, 05:34 AM
Starting a fighting game - by na_th_an - 05-25-2003, 05:46 AM
No, Na_th_an,.. - by Glenn - 05-25-2003, 05:51 AM
Re: No, Na_th_an,.. - by na_th_an - 05-25-2003, 05:55 AM
Starting a fighting game - by na_th_an - 05-25-2003, 06:35 AM
Starting a fighting game - by na_th_an - 05-25-2003, 07:27 AM
Read what you just... - by Glenn - 05-25-2003, 07:57 AM
Starting a fighting game - by na_th_an - 05-25-2003, 06:29 PM
Starting a fighting game - by toonski84 - 05-25-2003, 08:47 PM
Starting a fighting game - by Kofman - 05-26-2003, 01:10 AM
Starting a fighting game - by na_th_an - 05-26-2003, 01:42 AM
Starting a fighting game - by Kofman - 05-27-2003, 05:43 AM
Starting a fighting game - by Ninkazu - 05-27-2003, 06:39 AM
Starting a fighting game - by na_th_an - 05-27-2003, 08:33 AM
Starting a fighting game - by LooseCaboose - 05-27-2003, 02:47 PM
Yes, we've been over that... :) - by Glenn - 05-27-2003, 10:20 PM
Starting a fighting game - by LooseCaboose - 05-28-2003, 03:27 AM
Starting a fighting game - by Rokkuman - 05-28-2003, 07:01 AM
Starting a fighting game - by Kofman - 05-28-2003, 07:15 AM
Starting a fighting game - by Kofman - 05-30-2003, 03:14 PM
Starting a fighting game - by Ninkazu - 05-30-2003, 04:29 PM
You only multiply by 8 in mode 13... - by Glenn - 05-30-2003, 06:44 PM
Starting a fighting game - by na_th_an - 05-30-2003, 07:57 PM
Starting a fighting game - by Kofman - 05-31-2003, 11:51 PM
Starting a fighting game - by Kofman - 06-03-2003, 06:18 AM
Starting a fighting game - by Kofman - 06-03-2003, 06:52 AM
Starting a fighting game - by na_th_an - 06-03-2003, 07:11 PM
Starting a fighting game - by Kofman - 06-04-2003, 04:11 AM
Starting a fighting game - by relsoft - 06-04-2003, 08:09 AM
Starting a fighting game - by na_th_an - 06-04-2003, 09:08 AM
Starting a fighting game - by Kofman - 06-04-2003, 03:27 PM
Neopaint loads PCX pictures just fine. - by Glenn - 06-04-2003, 03:34 PM
Starting a fighting game - by wizardlife - 06-04-2003, 09:22 PM
Starting a fighting game - by toonski84 - 06-05-2003, 12:26 AM
Starting a fighting game - by Kofman - 06-05-2003, 03:18 AM
Starting a fighting game - by Kofman - 06-05-2003, 04:16 AM
Starting a fighting game - by na_th_an - 06-05-2003, 09:21 AM
Starting a fighting game - by wizardlife - 06-08-2003, 06:19 AM
Starting a fighting game - by Kofman - 06-10-2003, 04:39 AM
Starting a fighting game - by ak00ma - 06-10-2003, 12:04 PM
Starting a fighting game - by na_th_an - 06-10-2003, 05:11 PM
Starting a fighting game - by Ninkazu - 06-10-2003, 05:11 PM
Starting a fighting game - by wizardlife - 06-10-2003, 08:26 PM
Starting a fighting game - by Piptol - 06-10-2003, 10:44 PM
Starting a fighting game - by Kofman - 06-11-2003, 01:05 AM
Starting a fighting game - by Rokkuman - 06-11-2003, 02:59 AM

Forum Jump:


Users browsing this thread: 3 Guest(s)