Jump to content


JishHD

Member Since 26 Feb 2007
Offline Last Active Oct 25 2012 08:30 PM

Topics I've Started

Infinite Room: 99% Perfect.. but a slight stutter?

24 September 2010 - 03:47 AM

Hey all, got a problem here.
I have an infinite room wrapping code (integrated into all the objects in this concept game I'm putting together). Everything looks great, it runs smoothly and wraps objects and drawing perfectly. Except for one strange problem. My main character stutters for one frame when he passes over the "wrap line." This is very strange, because it doesn't happen with all the other moving objects that go across this line (such as moving dust balls).

First off, here is the executable for a simple test level. Controls are W for jump and A/D for moving. When you pass underneath the big arrow, you'll notice a slight glitch in the sprite.

http://www.box.net/shared/5qixobbimt

I have a feeling it's something to do with the view-following code in the main object's step event, but I'm not sure.
Here's some stats for the view:
height=240
width=144
wport=768
hport=432

// STEP EVENT
// left and right just check if the keys are being pressed
// this first section just scales the view, probably doesn't effect this problem
if left or right or y!=yprevious
    {
    moving=min(moving+0.5,5)
    }
if !right and !left and y=yprevious
    {
    moving=max(moving-0.5,0)
    }
if moving>=0
    {
    view_wview=wview*(1+moving/15)
    view_hview=hview*(1+moving/15)
    }
//this part actually makes the view follow the player, and wraps the player as well
var xx,yy;
realspeed=point_distance(x,y,xprevious,yprevious)
dir=point_direction(x,y,xprevious,yprevious)
xx=x-lengthdir_x(realspeed*3,dir)
yy=y-lengthdir_y(realspeed*3,dir)
view_xview=xx+sprite_width/2-view_wview/2
view_yview=yy+sprite_height/2-view_hview/2

if x>room_width
    {
    x=0
    }
else if x+sprite_width<0
    {
    x=room_width-sprite_width
    }

Screensave.dll Not Compatible With Gm8? [updated]

17 January 2010 - 08:22 PM

[UPDATE]
It appears that I've found the problem, and it has to do with the background being set as "opaque." I loaded up the tmp.bmp file as one of GM's background images, and when searching for the correct file I noticed a checkmark that says "Make opaque." When I checked that and loaded the background, it worked! However, how can I apply this when drawing the background in-game? I see no option to choose whether it is opaque or not...


I'm working on a simple screensaver program. When the computer is idle, the program uses screensave.dll to take a snapshot of the screen, and then draws that background and fades a filled rectangle over it to fade out the screen. When the mouse is moved or a button is pressed, it brightens and exits. This works PERFECTLY, except only in GM7. When I transfer it over to GM8 (after adapting the code to GM8's slight changes in function arguments), it seems to be incompatible with screensave.dll.

Here is a picture of the GM7 version, working perfectly.

Posted Image

And here's the glitched GM8 version. As you can see, for some reason it fills up various parts of the screen in gray (the default color of my Windows Classic theme, even though I'm running Vista). It also only shows the icons in some parts.

Posted Image

Here's what happens: The .dll saves the screen as "tmp.bmp" in the same directory as the game. Then, you use a piece of code to snag that picture and use it as a background. After checking the directory of the game while running this screensaver, I saw that tmp.bmp was CORRECT, with no errors, but when it is used by the game as an image, it fills up all those strange gray pieces.

Can anyone tell me what's going on? If you need me to, I can upload the GM7 and the GM8 versions of the .gmk.

Checking Script Outside_view Not Working

16 January 2010 - 08:23 PM

Hey all, haven't posted on these forums for a while :P

Anyway, my problem: I have this script that checks if a specific (x,y) coordinate is inside a designated view.

/*
outside_view(x,y,view#)
function: tests if a coordinate is outside the given view
returns: yes (1) or no (0)
*/

if view_xview[argument2]<0 {view_xview[argument2]=0}
if view_xview[argument2]+view_wview[argument2]>room_width {view_xview[argument2]=room_width-view_hview[argument2]}
if view_yview[argument2]<0 {view_yview[argument2]=0}
if view_yview[argument2]+view_hview[argument2]>room_height {view_yview[argument2]=room_height-view_wview[argument2]}

if argument0<view_xview[argument2]
or argument0>view_xview[argument2]+view_wview[argument2]
or argument1<view_yview[argument2]
or argument1>view_yview[argument2]+view_hview[argument2]
{return true} else {return false}

-In my current platformer game, I use this script to check which enemies are currently inside the view when the player targets available enemies.
-I also have a view running that follows the player object through the room.

Here is the code that runs through all objects and checks if it is visible (view is unobstructed) and inside the view:

while (run)
	{
	var halfhyp;
	halfhyp=hypo(view_wview,view_hview)/2 //hypo() finds the hypotenuse of a width and a length
	ins=instance_nearest_visible(view_xview+view_wview/2,view_yview+view_hview/2,obj_trox,obj_block,halfhyp,1)
	//obj_trox is the enemy object, halfhyp is the range to look from the center of the view to scan for enemies
	if !ins break;
	with (ins)
		{
		if !outside_view(x,y,view_current)
			{
			ds_list_add(other.listx,x)
			ds_list_add(other.listy,y)
			instance_deactivate_object(id)
			}
		else
			{
			run=false
			}
		}
	}

And here's a picture of the problem. As you can see, it doesn't select all the available enemies inside the view, just within a certain distance. I'm not sure what is causing this..

Posted Image

[EDIT]
If I remove the !outside_view if statement, then it works great, except it can still find enemies outside the borders of the room if they are within the halfhyp range.


Thank you for any help you can give!

Strange Gravity Problem When Pausing

04 July 2009 - 05:23 AM

I'm noticing a strange problem when pausing (using instance deactivation) when airborne. If I jump in the air (using normal gravity and speed codes) and then pause, it seems that the vertical speed builds up while the object is deactivated. When I stop pausing, the object will shoot downward at a much faster pace than normal, sometimes disrupting game play. There's nothing special about the codes I'm using, but if you need me to post them just let me know.

Does anyone know why this happens or how to fix it?


EDIT: I added a speed cap in the step event which seems to stop the problem, and now I'm beginning to think this was just an illusion...I'll change it if I still have problems, but for now I think this is solved.

Saving And Ordering Object Distances

03 July 2009 - 06:59 AM

Ok, here's my problem:

I'm trying to create a ds_list of all instances (IN the view), ordered from least to greatest distance from the player object. I'm not really too sure how to go about doing this as I don't have much skill in the use of ds_lists and their ordering, however I know ds_list_sort can order values in ascending to descending.

What I have so far...am I going in the right direction?

inviewlist=ds_list_create()
nearlist=ds_list_create()
imbx=obj_imb.x //player coordinates
imby=obj_imb.y

with (obj_trox) //enemy object
	{
	if !outside_view(x,y,view_current) //script checks if coordinates are outside the view
		{
		ds_list_add(inviewlist,id)
		ds_list_add(nearlist,point_distance(x,y,imbx,imby)
		}
	}

var i,s;
s=ds_list_size(inviewlist)
for (i=0;i<s;i+=1)
	{
	>>>What goes here? How would I order it?<<<
	}


My ideal output of this code would be a ds_list with the id #'s of all the obj_trox inside the view ordered from least distance to greatest distance from obj_imb. It's late, so I'm probably over-thinking this or I'm doing something obvious very wrong, so if someone could steer me in the right direction it would be much appreciated :whistle: