Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Why is this not working?

Author
Message
Zeus
20
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 12th Jul 2010 22:26
The code I am posting should check for collision (pixelcol) on every sprite. Instead it is just checking the last number for collision. How can I fix it? Here is my code.

Main.dba


Functions.dba


Made with the latest DBP update if that matters.

Thanks!
Zeus

Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 12th Jul 2010 22:42
I think your problem is that you want to set up a 3D view with 2D sprites and your checking pixels to determine if there is a collision...... Are you trying to make a SYM like SYM CITY? If so, I would not worry about collisions. You have your grid made. Just use an array to determine if the plot is taken by something and as far as render order, you can use sprite priority to make sure they are rendered properly. If you are going to rotate your view, you can use billboards instead of sprites and there is a rendering command that will automatically do a z-buffer test for transparent spots on your billboard. Im not at my home pc now, but I think it's in the "texture object" section.

The fastest code is the code never written.
Zeus
20
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 13th Jul 2010 00:51
See, I must do 2d because I am building this to be a FB app with AS when I am through with this. And I will see what I can do with arrays again.

Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 13th Jul 2010 03:32
You posted another related question and arrays were brought up there too. If you have problems understanding/implimenting arrays, let me know.

What's FB? AS?

The use of sprites is simple if you don't want to rotate the view. Are you rotating?

The fastest code is the code never written.
Zeus
20
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 13th Jul 2010 07:17
Facebook and ActionScript.

I am having trouble understanding. I know how to create and insert, but how do I check for collision a save the array for future loading?

I will be rotating sprites.

Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 13th Jul 2010 15:26
What collisions are you concerned about? If you are simply trying to make sure you don't get two "properties" in the same grid location, then that's what the array will do for you..... So, what collisions?

The fastest code is the code never written.
Zeus
20
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 13th Jul 2010 18:52 Edited at: 13th Jul 2010 18:53
How do I check if they are in the same tile?

Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 13th Jul 2010 23:51 Edited at: 13th Jul 2010 23:54
Quote: "How do I check if they are in the same tile?"


Find their relative positions and use that to see if they are in the same tile. You can do this by simply checking if they are the same when rounded down:



[edit] Only works when the coordinates are positive. If they can be both positive and negative then you'll have to alter this a little so int() will round to the first whole number smaller than the actual one.

Cheers!
Sven B

Zeus
20
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 14th Jul 2010 02:40
What values are placed in the RelPos variables?

Sorry to bother, I just have no experience with this whatsoever.

Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 14th Jul 2010 03:14
A simple explaination of a 2D array (MyArray(10,10)):
The syntax would be:

Think of a grid with 10 across and 10 down and each of the grid positions can have an integer as it's value. It doesn't have to be an integer, it can be any data type. This example would give you a total of 100 integers. So if I wanted to place a value of 5 at position 5,3 (on our grid/array) I would use this syntax:

You can simply think of the array coordinates (elements) as individual variables that are kept in a neat package.

Does it make more sinse?

The fastest code is the code never written.
Zeus
20
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 14th Jul 2010 04:31
I understand that, so how would I check if they are in the same tile with the array? I understand how to insert and create the array...

Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 14th Jul 2010 05:43 Edited at: 14th Jul 2010 05:43
You are using a grid pattern right? That's just like a 2D array. Each "block" of your city has the possibility of having:
0=empty lot
1=residential house
2=factory
etc.... for example.

Those are the possible numeric values of each element in the array which represents a city block.

Understand?

The fastest code is the code never written.
Zeus
20
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 14th Jul 2010 06:24
Yes.

Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 14th Jul 2010 13:14
Quote: "What values are placed in the RelPos variables?"


I think I showed you how to do this once. It's the part that belonged with this:



coordX# and coordY# are the relative position components (the variables that I meant by RelPos*#).

Cheers!
Sven B

Zeus
20
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 14th Jul 2010 17:10
Oh, I see. Thanks Sven B! You have really handy, I will put your username in the game credits, you too Hawxblood.

Login to post a reply

Server time is: 2026-07-25 16:20:07
Your offset time is: 2026-07-25 16:20:07