[QUOTE=quincy18;30492580][img]http://i54.tinypic.com/bfgu50.png[/img][/QUOTE]
Looks like a retarded creeper.
Could you make a rounded corner image and use that for each connecting corner? That should be easier on memory.
[QUOTE=quincy18;30492580]I'm currently trying to make my tile-engine use a 10 piece tileset to make the tiles like this :
[img]http://i54.tinypic.com/bfgu50.png[/img]
So this is just done by hand but I need it to be done automaticly (for if a block is removed), the only way I could think of right now is just 10 if statements witch each 9 conditions in it (for each of the surrounding blocks) but that seems a bit messy. Is there a better way to do this ?[/QUOTE]
I'd make a simple map for mapping each tile's neighbourhood to an integer using bit flags or something.
[code]int neighbourhood = (tiles[x - 1, y - 1].solid << 8) |
(tiles[x, y - 1].solid << 7) |
(tiles[x + 1, y - 1].solid << 6) |
(tiles[x - 1, y ].solid << 5) |
(tiles[x, y ].solid << 4) |
(tiles[x + 1, y ].solid << 3) |
(tiles[x - 1, y + 1].solid << 2) |
(tiles[x, y + 1].solid << 1) |
(tiles[x + 1, y + 1].solid);[/code]
(assuming solid is 0 when not solid, 1 when solid)
It produces an integer between 0-511 (inclusive) that uniquely represents the region formed by the 9 tiles.
If you're only interested in the 4-neighbourhood (only up, down, left, right matter), it reduces to 16 possible states instead of the 512 possible states with the 9-neighbourhood with the tile itself included. That in turn can be further reduced to produce the 10 possible states your tilemap has.
[editline]16th June 2011[/editline]
It's not a big deal with just 10 possible states. My technique requires no branching, which makes it better for big neighbourhoods.
[QUOTE=meepugh;30490620]I just started using Python, and whenever I save a program in the idle, all the text turns black. Some of the stuff is usually orange, green, ect, depending on what I write.
Anyone know how to fix this? Or am I doing something wrong?[/QUOTE]
Add .py to the end when you save it, IDLE doesn't do it for you.
I currently have this :
[code]
int index;
if(x + 1 < width)
index = baseMap[y * width + x + 1] > 0 ? Right : 0;
else
index = Right;
if(y + 1 < height)
index |= baseMap[y + 1 * width + x] > 0 ? Bottom : 0;
else
index |= Bottom;
if(x - 1 > 0)
index = baseMap[y * width + x - 1] > 0 ? Left : 0;
else
index = Left;
if(y - 1 > 0)
index |= baseMap[y - 1 * width + x] > 0 ? Top : 0;
else
index |= Top;
[/code]
so that should give me a number between 1-15 depending on the surrounding 4 blocks, now do I just add 10 if statements to check for each block type or ?
Compiling error. I am sleepy so i must be missing something simple, but i am not seeing anything wrong with my code. Nor does the error seem to make any sense in this situation.
[cpp]
NTSTATUS SetFilter(PacketFilterExtensionPtr filterFunction) // Line 59
{
NTSTATUS status = STATUS_SUCCESS;
PF_SET_EXTENSION_HOOK_INFO filterData;
filterData.ExtensionPointer = filterFunction;
KEVENT event; // Line 66
KeInitializeEvent(&event, NotificationEvent, FALSE);
UNICODE_STRING filterName;
PDEVICE_OBJECT ipDeviceObject=NULL;
PFILE_OBJECT ipFileObject=NULL;
RtlInitUnicodeString(&filterName, DD_IPFLTRDRVR_DEVICE_NAME);
status = IoGetDeviceObjectPointer(&filterName,STANDARD_RIGHTS_ALL, &ipFileObject, &ipDeviceObject);
IO_STATUS_BLOCK ioStatus;
PIRP irp = IoBuildDeviceIoControlRequest(IOCTL_PF_SET_EXTENSION_POINTER,
ipDeviceObject,
(PVOID) &filterData,
sizeof(PF_SET_EXTENSION_HOOK_INFO),
NULL,
0,
FALSE,
&event,
&ioStatus);
if(irp != NULL)
{
NTSTATUS waitStatus=STATUS_SUCCESS;
status = IoCallDriver(ipDeviceObject, irp);
if (status == STATUS_PENDING)
{
waitStatus = KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
}
}
if(ipFileObject != NULL)
ObDereferenceObject(ipFileObject);
ipFileObject = NULL;
ipDeviceObject = NULL;
return status;
}[/cpp]
[code]
P:\DRIVERS\DEVNULL>build
BUILD: Compile and Link for x86
BUILD: Loading c:\winddk\7600.16385.1\build.dat...
BUILD: Computing Include file dependencies:
BUILD: Start time: Thu Jun 16 19:29:41 2011
BUILD: Examining p:\drivers\devnull directory for files to compile.
p:\drivers\devnull Invalidating OACR warning log for 'root:x86chk'
BUILD: Saving c:\winddk\7600.16385.1\build.dat...
BUILD: Compiling and Linking p:\drivers\devnull directory
Configuring OACR for 'root:x86chk' - <OACR on>
Compiling - main.c
1>errors in directory p:\drivers\devnull
1>p:\drivers\devnull\main.c(66) : error C2275: 'KEVENT' : illegal use of this ty
pe as an expression // Right here.
1>p:\drivers\devnull\main.c(66) : error C2146: syntax error : missing ';' before
identifier 'event'
1>p:\drivers\devnull\main.c(66) : error C2065: 'event' : undeclared identifier
1>p:\drivers\devnull\main.c(67) : error C2065: 'event' : undeclared identifier
1>p:\drivers\devnull\main.c(69) : error C2275: 'UNICODE_STRING' : illegal use of
this type as an expression
1>p:\drivers\devnull\main.c(69) : error C2146: syntax error : missing ';' before
identifier 'filterName'
1>p:\drivers\devnull\main.c(69) : error C2065: 'filterName' : undeclared identif
ier
1>p:\drivers\devnull\main.c(71) : error C2275: 'PDEVICE_OBJECT' : illegal use of
this type as an expression
1>p:\drivers\devnull\main.c(71) : error C2146: syntax error : missing ';' before
identifier 'ipDeviceObject'
1>p:\drivers\devnull\main.c(71) : error C2065: 'ipDeviceObject' : undeclared ide
ntifier
1>p:\drivers\devnull\main.c(72) : error C2275: 'PFILE_OBJECT' : illegal use of t
his type as an expression
1>p:\drivers\devnull\main.c(72) : error C2146: syntax error : missing ';' before
identifier 'ipFileObject'
1>p:\drivers\devnull\main.c(72) : error C2065: 'ipFileObject' : undeclared ident
ifier
1>p:\drivers\devnull\main.c(74) : error C2065: 'filterName' : undeclared identif
ier
1>p:\drivers\devnull\main.c(75) : error C2065: 'filterName' : undeclared identif
ier
1>p:\drivers\devnull\main.c(75) : error C2065: 'ipFileObject' : undeclared ident
ifier
1>p:\drivers\devnull\main.c(75) : error C2065: 'ipDeviceObject' : undeclared ide
ntifier
1>p:\drivers\devnull\main.c(78) : error C2275: 'IO_STATUS_BLOCK' : illegal use o
f this type as an expression
1>p:\drivers\devnull\main.c(78) : error C2146: syntax error : missing ';' before
identifier 'ioStatus'
1>p:\drivers\devnull\main.c(78) : error C2065: 'ioStatus' : undeclared identifie
r
1>p:\drivers\devnull\main.c(79) : error C2275: 'PIRP' : illegal use of this type
as an expression
1>p:\drivers\devnull\main.c(79) : error C2146: syntax error : missing ';' before
identifier 'irp'
1>p:\drivers\devnull\main.c(79) : error C2065: 'irp' : undeclared identifier
1>p:\drivers\devnull\main.c(80) : error C2065: 'ipDeviceObject' : undeclared ide
ntifier
1>p:\drivers\devnull\main.c(86) : error C2065: 'event' : undeclared identifier
1>p:\drivers\devnull\main.c(87) : error C2065: 'ioStatus' : undeclared identifie
r
1>p:\drivers\devnull\main.c(90) : error C2065: 'irp' : undeclared identifier
1>p:\drivers\devnull\main.c(93) : error C2065: 'ipDeviceObject' : undeclared ide
ntifier
1>p:\drivers\devnull\main.c(93) : error C2065: 'irp' : undeclared identifier
1>p:\drivers\devnull\main.c(96) : error C2065: 'event' : undeclared identifier
1>p:\drivers\devnull\main.c(100) : error C2065: 'ipFileObject' : undeclared iden
tifier
1>p:\drivers\devnull\main.c(101) : error C2065: 'ipFileObject' : undeclared iden
tifier
1>p:\drivers\devnull\main.c(103) : error C2065: 'ipFileObject' : undeclared iden
tifier
1>p:\drivers\devnull\main.c(104) : error C2065: 'ipDeviceObject' : undeclared id
entifier
Linking Executable - objchk_win7_x86\i386\adevnull.sys
1>link : error LNK1181: cannot open input file 'p:\drivers\devnull\objchk_win7_x
86\i386\main.obj'
BUILD: Finish time: Thu Jun 16 19:29:43 2011
BUILD: Done
3 files compiled - 23 Warnings - 34 Errors
1 executable built - 1 Error
[/code]
Thanks for you time.
EDIT: Fixed it, always declare your variables at the top of the function when writing windows kernel drivers.
Sounds like you missed a } before that line.
[QUOTE=slashsnemesis;30493891]Add .py to the end when you save it, IDLE doesn't do it for you.[/QUOTE]
Thanks a lot!
[QUOTE=Staneh;30475925]I want to create a 10x10cm square, with 1cm blocks, now, I want to do this with 1-for loop. But, how would I do this with just 1 for loop? I know how to do it with 10, but, I want to learn it the fast way.[/QUOTE]
[code]
for(int i = 0; i > 99; i++)
{
int x = i % 10;
int y = i / 10;
}
[/code]
Co-ords of first block (top left) are [0, 0]
So hey guys, im trying to make this simple lighting circle thing that should add its alpha value to the tile it invades IF the current light source tile is lower than the selected one to invade And im REALLY stuck.
Heres what i got so far...
[code]
function Lighting:CreateSphere(x, y, r, int)
x = x - 1
y = y - 1
local length_x = ((x - r) + (r * 2)) -- get the postition of X + the length of the box to get the total width
local length_y = ((y - r) + (r * 2)) -- get the postition of y + the length of the box to get the total height
for i = x - r, length_x do
for k = y - r, length_y do
local distance = self:Dist(x,y,i,k)
local gradient = 255-(int*(1-(distance/r)))
if i < self:Conv(scrn) and i > 0 and k < self:Conv(scrn) and k > 0 then
if gradient <= overlay[i][k] then
overlay[i][k] = gradient
end
end
end
end
end
[/code]
each overlay holds its own alpha value, this is REALLY annoying me now.
it doesn't work at all but i think it kinda shows what i wanna do
Not *entirely* programming, but everyone here is most likely to know
I've followed the tutorial here ( [url]http://honeypod.blogspot.com/2007/12/dynamically-linked-hello-world-for.html[/url] ), blah blah blah everything compiled etc
Where do i actually stick the program on my device though? :v: (This is my actual android device)
What kind of file did it make? If it's a ... apk I think (Android Package?) you can just drop it on your SD card and then enable "Allow apps that arent' from marketplace" in one of the settings menu. Then use something like Astro to browse to the apk and run it.
[QUOTE=Lord Ned;30501857]What kind of file did it make? If it's a ... apk I think (Android Package?) you can just drop it on your SD card and then enable "Allow apps that arent' from marketplace" in one of the settings menu. Then use something like Astro to browse to the apk and run it.[/QUOTE]
It seems to have just made a binary
[QUOTE=Azur;30500953][code]
for(int i = 0; i < 100; i++)
{
int x = i % 10;
int y = i / 10;
}
[/code]
Co-ords of first block (top left) are [0, 0][/QUOTE]
Fixed that for you
[QUOTE=Icedshot;30501778]Not *entirely* programming, but everyone here is most likely to know
I've followed the tutorial here ( [url]http://honeypod.blogspot.com/2007/12/dynamically-linked-hello-world-for.html[/url] ), blah blah blah everything compiled etc
Where do i actually stick the program on my device though? :v: (This is my actual android device)[/QUOTE]
Plug it in via the USB cable and enable the Developer mode to allow USB debugging and so on.
Then you can run it from Eclipse and it'll install it on your phone for you.
[QUOTE=Chris220;30502375]Plug it in via the USB cable and enable the Developer mode to allow USB debugging and so on.
Then you can run it from Eclipse and it'll install it on your phone for you.[/QUOTE]
I would rather have a command line solution, because otherwise ill have to install a whole ide just to use the one function.. but ill try it in a bit if i cant find any other solutions!
Oh right I didn't realise you weren't using an IDE :v:
I'm not sure how to do it without Eclipse, my brief foray into Android dev didn't last very long
I'm going to murder someone. ( :v: ) Cannot for the life of me work out how its supposed to work. Ive tried whatever the adb thing is, and none of the commands work (Permissions denied! Both in cygwin and cmd, with administrator privileges), so, any pointers would be appreciated!
Sigh, im a moron. You need a rooted device.
Though now, having copied it across, its telling me that i dont have permission to run the file. In adb. Damnnabbit
I have a small question about Pygame. I have a little shoot'em up game that I made and I want to make it so when I hold down the shoot button it begins charging up a shot and the longer you hold it the larger the shot becomes but I don't know how to check how long any key has been held down. Anyone know how this is achieved?
-wrong thread-
I'm having trouble with building a word-wrap for my text-drawing.
I can get the width of a string in pixels, and I can insert a new line at whatever place in the string I need to and it'll draw that on a new line. However, I'm having issues where it only measures correctly when the ENTIRE SENTENCE IS IN CAPS THANKS TO USING A NON-MONOSPACE FONT.
However, Monospace fonts will not always be used so I need a way to support non-monospaced fonts... Any theory here would be great.
Here's a visualization:
[img]http://i54.tinypic.com/2cp9ftx.png[/img]
[b]Both of these strings are input'd the same way. I'd like the non-all caps one to go to the same width in the window as the ALL CAPS one.[/b]
Here's my code:
[csharp]
//Figure out the number of chars per line
//window.Width is the width of the window in pixels, textPadding (8) is the padding from each side of the window in pixels,
//and fontSize.X is determined by: fontSize = new Vector2(ConsoleFont.MeasureString("X").X, ConsoleFont.MeasureString("Xy").Y);
logWidthInChars = (int) ((window.Width - textPadding * 2.0f) / fontSize.X);
...
string logEntry = entry.ToString();
if (logEntry.Length > logWidthInChars)
{
string logEntry = entry.ToString();
if (logEntry.Length > logWidthInChars)
{
//It was longer, replace with \n so it moves down.
logEntry = logEntry.Insert(logWidthInChars - 5, "\n");
}
}
[/csharp]
Is it C#? C# has some nifty utility functions for that.
Is there a significant performance increase when you use OpenGL VAOs? I'm considering using them, but want to allow scaling back to OpenGL 2.0, so I'll have to do a bit more work to see if VAOs are supported and not use them if they aren't.
How would I go about sending a POST request in java, where one of the parameters needs to be an image file? I keep getting 400 bad request errors. and every tutorial I can find has some problem or another and it's driving me mental :byodood:
iirc, display lists should be about as efficient as VBOs. VAOs are less efficient, because the attributes are stored in client-memory.
[editline]17th June 2011[/editline]
[url]http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=246468[/url]
[QUOTE=Nigey Nige;30515279]How would I go about sending a POST request in java, where one of the parameters needs to be an image file? I keep getting 400 bad request errors. and every tutorial I can find has some problem or another and it's driving me mental :byodood:[/QUOTE]
Read about the [url=http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4]form content types[/url]; you should use multipart/form-data, not application/x-www-form-urlencoded. And put the form data in the body of your POST, not in the URL. Servers impose length limits on URLs, so putting the entire contents of a file into a URL is a bad idea.
[editline]17th June 2011[/editline]
[QUOTE=esalaka;30492368]Haha nobody ever told me operator() is overloadable :v:[/QUOTE]
Yes, and it can be [url=http://en.wikipedia.org/wiki/Function_object]quite useful[/url].
[QUOTE=Wyzard;30516225]Yes, and it can be [url=http://en.wikipedia.org/wiki/Function_object]quite useful[/url].[/QUOTE]
Callbacks.
Fuck yeah.
[editline]17th June 2011[/editline]
"An advantage of function objects in C++ is performance because, unlike a function pointer, a function object can be inlined." Wait are you telling me an useful function actually can [B]increase performance[/B]?
This is like C++ did something right for a change!
I've coded this for handling the enemy that are in my game and I cannot help but feel that the code is terrible, could someone take a look at it and tell me where I could prove it please.
[url]http://pastebin.com/GyHZS6JY[/url]
[QUOTE=Jimmylaw;30516801]I've coded this for handling the enemy that are in my game and I cannot help but feel that the code is terrible, could someone take a look at it and tell me where I could prove it please.
[url]http://pastebin.com/GyHZS6JY[/url][/QUOTE]
I think yuo can do
enemy = new Enemy[10]();
Not that it matters much but saves you doing a foreach
Also you seem to only use Index in load, therefore theres no need to have it in the main class.
just create it in the load method
[QUOTE=Richy19;30516930]I think yuo can do
enemy = new Enemy[10]();
Not that it matters much but saves you doing a foreach
Also you seem to only use Index in load, therefore theres no need to have it in the main class.
just create it in the load method[/QUOTE]
"enemy = new Enemy[10]();" doesn't appear to work, it errors.
How does the XNA Color class' PackedValue property work?
As in how can I convert a rgba value to PackedValue without using the PackedValue property?
I've tried this
[csharp]
private uint ColorToUInt(Color color)
{
return (uint)((color.A << 24) | (color.R << 16) |
(color.G << 8) | (color.B));
}
[/csharp]
but it doesn't produce the same values as the PackedValue.
Example:
PackedValue property = 4285797122
My method = 4278326132
[editline]17th June 2011[/editline]
Never mind. I got it working!
Sorry, you need to Log In to post a reply to this thread.