Author Topic: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)  (Read 178707 times)

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #390 on: July 08, 2011, 10:02:10 AM »
Thanks for posting the screenshot, makes a lot of things clear.

First of all, what you are seeing here is not a mistake of drawing-order, but a mistake of positioning. Just take a look at your own code:
  • Floor is positioned at: DrawGraphic3D(0,0,0);  That means it is the center of X, center of Y axis and center of Z axis. With   SetGraphicRect(0,0,512,512);
  • Your shelf is positioned at:  DrawGraphic3D(80,20,-20); with   SetGraphicRect(0,0,512,512);

I am questioning whether you understand the usage of DrawGraphic3D. Let me explain to you:
- first number indicates where the object is placed on the X-axis (left or right)
- second number indicates how high the object is placed on the Y-axis (lower or higher)
- third number indicates how far or close the object is on the Z-axis (close / far)

[attach=1]

Notice how I marked the red dots and put the coordinates to them? That is how you should imagine your own stage. Your floor is at 0,0,0 meaning ANYTHING that you want to be higher than your floor, must have a Y-parameter greater than 0.

Ok now try to follow and think along:
You are positioning your shelf at Y axis: 20 (see the lime green highlighted number).  Notice how the floor is positioned at 0? Basically it is your own fault for placing the shelf 'half-way' into the floor. GraphicRect indicates how big the object is suppose to be drawn. If you use 0,0,512,512 it means it will use the texture sizes X = 0 - 512  and Y = 0 - 512.  Aka the object is 512x512 large at a scale of 1,1. Scale influences the graphicrect by stretching it so a 2,2 scale still uses the texture size 512x512 but STRETCHES the object to 1024x1024.

TL DR; your shelf is misplaced. Raise the Y-axis for your shelf, like at  DrawGraphic3D(80,256,-20); Because the center of your shelf-graphicrect = 0,0 and thus technically it has from that center point, 256 to the left, 256 to the right forming 512 on the X-axis. 

3D objects don't behave the same like Effect Objects where you have to use vertexes to define the shape and size. Because these are background functions, they can be easily placed.

« Last Edit: July 08, 2011, 10:05:46 AM by Helepolis »

Darkness1

  • Nothing to see here.
  • Enigmatic, isn't it?
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #391 on: July 08, 2011, 11:12:37 AM »
To think that after all the time i had coded in danmakufu i didn't know such a simple thing... It makes more sense now, thanks!

But I'm still not so used to using the z-axis, nor do i know everything about it.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #392 on: July 08, 2011, 12:22:21 PM »
To think that after all the time i had coded in danmakufu i didn't know such a simple thing... It makes more sense now, thanks!

But I'm still not so used to using the z-axis, nor do i know everything about it.

Z-axis is used to put things closer or futher away from you. As you know, there are 2 methods of stage scrolling:
- Texture scrolling (just like in 2D drawing, scrolling the graphicrect)
- Moving 3Dobjects and resetting them each time.

It is kind of tricky to explain, perhaps a picture again:
[attach=1]

Here is what you do (this will show you why fuctions are going to be your friend for the rest of your 3D-stage making life):
- You create a variable called 'scroll' or w/e (let scroll = 0;)
- Place your floors exactly as they show up in the picture so Floor 1 = createFloor(0,0,0);  Floor 2 =  createFloor(0,0,-1024);  Floor 3 =  createFloor(0,0,-2048);  (make sure you angle them proper so the Y-side is the longer length.

add the variable scroll to all Z parameters so it becomes:
- Place your floors exactly as they show up in the picture so Floor 1 = createFloor(0,0,0+scroll); Floor 2 =  createFloor(0,0,-1024+scroll);  Floor 3 =  createFloor(0,0,-2048+scroll);

Now add at the end of your background loop or w/e    scroll+=4;  (or at the speed you wish to scroll) and if(scroll>2048) { scroll = 0; }

So what will happen now?
All the floor pieces will start moving closer to you. Because a negative value means the floor is away from you and is being moved towards you (by the scroll value). However, once the scroll variable hits 2048, all the floors will be re-setted back to their original location (because scroll = 0).

Now this will look very stupid if you leave it like this, but if you hide the last floor piece with a dense fog, the player won't even notice the floors being reset because the eyes will be fooled as if the floor pieces keep on coming. Logically, this requires repeating textures for all floors or plain texture, else it will be noticeable. And this is why the most creative builders will fool you with the SetFog.

Just to be warned, you won't probably get it the first time. I didn't either. Takes a lot of trial and error.
- Don't rush it
- Don't try to move EVERYTHING in one go.
- Do it step by step. Create the floors, move them. Use fog to hide the "resetting". Then carry on with the bookshelves.
« Last Edit: July 08, 2011, 12:35:33 PM by Helepolis »

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #393 on: July 08, 2011, 05:41:23 PM »
Adding on to this, some of you may be wondering why you would go through the trouble of moving everything else when you can just move the camera and reset the camera's position after a bit while using fog to hide it.

LO AND BEHOLD! Another quirk of Danmakufu that causes fog to lag behind by a frame when calculating distance. For example, if your camera were at the position (0, 0, 0) and you move it to (0, 0, 10), when you render the fog, it'll still think the camera were at (0, 0, 0). It doesn't matter if you set the camera's position before or after you set the fog. Now this might seem negligible, but imagine the case where you want to reset the position of the camera. If the camera were at (0, 0, 2048) and you wanted to reset it to (0, 0, 0), when Danmakufu draws fog, it'll think the camera were still at (0, 0, 2048) for one frame, and quite likely you'll have a super thick cover of fog when there shouldn't be any. This will cause a very noticeable flash of your fog's color every time you reset the camera's position.

Of course, one
Spoiler:
bad
solution is to never reset the camera, but there's an upper limit to how big of a number can be stored in a variable, especially when Danmakufu stores everything as a float. Then there's the headache of cleaning up all the objects that have passed the camera while generating new stuff behind the fog.
<WorkingKeine> when i get home i just go to the ps3 and beat people up in blazblue with a loli
<Azure> Keine: Danmakufu helper by day, violent loli by night.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #394 on: July 08, 2011, 10:50:43 PM »
Oh I didn't knew about that one yet Blargel. Wonders and mysteries of good 'Ol Danmakufu huh?

I wonder when that author is going to release a beta of the new Danmakufu engin. We checked the website, but still the same alpha version.

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #395 on: July 09, 2011, 12:36:54 AM »
I CANNOT FIGURE THIS OUT!!! It's been irritating the crap out of me and I've tried everything I can think of and then some >.< I want this spellcard to form two circles (black and white) on either side of the boss and then I want these circles to travel above the boss but still at GetCenterX and remain there until further scripting. All I can do is make the bullets spiral or travel in a straight line to that point!!! In the script at the moment, the bullets only travel in a straight line, even though I have the formulas for circular movement (thanks Ginko!). My only thought was to make my own user-defined bullets of the circles using a printscreened shot and assign them an angular velocity, but I also can't get background to initialize for some reason, even though the code is right there, so I have no neutral color to eliminate in order to capture bullet sprites. If anyone knows what's going on, either with my background loop, my circles, or both, your help would be greatly appreciated! Script is here: http://pastebin.com/KTugyq61

And I guess that's my daily question >.<

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #396 on: July 09, 2011, 12:51:01 AM »
Weird thing :

In your "bullet" task :
Code: [Select]
loop{
 
if(t==120){
 
Obj_SetPosition(obj,GetCenterX,Obj_GetY(obj) - 2);
 
}
wait(4);
}

You might have inverted the loop and the if : here, you'll never get out of the loop, and if t is not equal to 120 (which is the case), you're stuck in a loop that does nothing. What you want is to enter the loop if t is equal to 120.

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #397 on: July 09, 2011, 01:00:27 AM »
Ok, that got rid of the straight line issue...sorry, I always mix up where I put ifs with where I normally put whiles in a task >.< So how do I make the circle move on its own without turning into a line or spiral?

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #398 on: July 09, 2011, 01:04:27 AM »
Code: [Select]
Obj_SetSpeed(obj,0);
 :derp:

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #399 on: July 09, 2011, 01:14:26 AM »
Now I get this weird-ass twitchy thing >.< http://pastebin.com/q2h6qG1f

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #400 on: July 09, 2011, 01:18:12 AM »
Speed should be 0 from the start.

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #401 on: July 09, 2011, 01:23:54 AM »
It still twitches... Am I placing a loop wrong or something??? >.< http://pastebin.com/x6nPEsYB

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #402 on: July 09, 2011, 01:34:29 AM »
Code: [Select]
loop{
Obj_SetPosition(obj,GetCenterX,Obj_GetY(obj) - 30);
}

I'll get angry if you keep doing this ...

yield; is your friend.

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #403 on: July 09, 2011, 01:39:15 AM »
I'm sorry :( I really want to fix this, and I know I'm irritating...I'll stop asking questions, although this is really a small fraction of the questions I have...Sorry again :(

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #404 on: July 09, 2011, 01:49:03 AM »
Uh no, I didn't mean you have to stop asking questions; I just want you to remember you have to check you use the yield; when it's necessary (in particular, there has to be one in your loops, or else all of it will be done at once, which is sort of a problem if your loop is infinite).

All we want is to help you release your scripts, so don't refrain from asking questions.

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #405 on: July 09, 2011, 01:54:10 AM »
Right, sorry...misunderstood >.<

On that note...can you help me figure out why my background won't load?

And now I end up with slanted bullets... http://pastebin.com/fcuyJG3d WHAT THE HELL AM I DOING WRONG?!

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #406 on: July 09, 2011, 02:25:07 AM »
Code: [Select]
loop{
Obj_SetPosition(obj,Obj_GetX(obj) + 2,Obj_GetY(obj) - 2);
yield;
 
}
Each frame you add 2 to the object's x-coordinate and remove 2 from its y-coordinate, so it's ... normal if it's slanted.

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #407 on: July 09, 2011, 02:27:52 AM »
Alright, so then how do I keep the circle as a cohesive object (i.e. no slanting or spiraling) and move it to a different location without it coming apart?

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #408 on: July 09, 2011, 02:36:39 AM »
One thing you should consider is using that useless delay variable for this :

task fire{
let firedelay=0;
loop{
 
loop(60){
       
bullet(GetX-100,GetY,0,180,119,firedelay);
shot(GetX+100,GetY,0,180,247,firedelay);
 
wait(7);
firedelay=firedelay+7;
}
wait(320);
}
}


And then later in your task

task bullet(x,y,v,dir,graphic,delay){
 
let obj=Obj_Create(OBJ_SHOT);
let t = delay;
let z = 0.02;
 
Obj_SetPosition(obj,x,y);
Obj_SetSpeed(obj,v);
Obj_SetAngle(obj,dir);
ObjShot_SetGraphic(obj,graphic);
ObjShot_SetDelay(obj,0);
ObjShot_SetBombResist(obj,false);
...

if(t==420){

...

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #409 on: July 09, 2011, 02:45:08 AM »
Alright, that'll really help! Now about moving the circles without losing the shape...any suggestions or should I just find a way to make them user defined and give them an angular velocity?

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #410 on: July 09, 2011, 02:49:27 AM »
Well what i wrote above was just for that, the key point is to give your bullets a "common timer", so if you fire your bullet bullet_i at the time t_i and you want them to move together at the time T, you can start a counter for bullet_i at t=t_i and make the new stuff happen when t equals T.

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #411 on: July 09, 2011, 09:51:08 PM »
The counter variable makes a lot of sense, but the bullets stilll file out in lines...am I calling parameters for the object bullet wrong? http://pastebin.com/KhNscDT5 This is so frustrating >.< Thanks for all of your patience  ^_^

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #412 on: July 09, 2011, 10:02:54 PM »
Uh, i didn't put it in red last time, but still ... what did you think that firedelay variable was for ?

task fire{
let firedelay=0;
loop{
 
loop(60){
       
bullet(GetX-100,GetY,0,180,119,firedelay);
shot(GetX+100,GetY,0,180,247,firedelay);
 
wait(7);
firedelay=firedelay+7
}

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #413 on: July 10, 2011, 12:00:58 AM »
Gah! Total hurr durr moment >.< Now I get this weird ass glowing on the white circle and then the bullets file out...in a straight line >.< http://pastebin.com/cuA8Uwst

Also, I'm trying to reset the counters of f and t so that the process loops, but I can't seem to put the f = 0; or t = 0; in the right place...any ideas?

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #414 on: July 10, 2011, 12:23:15 AM »
You forgot to set the delay to 0 in your "shot" task.

If you want to process to loop completely, move the "let firedelay=0" clause.

task fire{
let firedelay=0;
loop{
 let firedelay=0;
loop(60){
...

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #415 on: July 10, 2011, 12:47:30 AM »
This all helps smooth things out, but my circles still won't move as cohesive units, only as lines DX I wish I could figure out what I'm doing wrong and stop bugging you guys :/

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #416 on: July 10, 2011, 02:17:33 AM »
task fire{
let firedelay=0;
loop{
 
loop(45){
       
bullet(GetX-100,GetY,0,180,119,firedelay);
shot(GetX+100,GetY,0,180,247,firedelay);
 
wait(7);
firedelay=firedelay+7 (why did you change that ?)
}
wait(320);
}
}
 
task bullet(x,y,v,dir,graphic,delay){
 
let obj=Obj_Create(OBJ_SHOT);
 
let t = 0;
Obj_SetPosition(obj,x,y);
Obj_SetSpeed(obj,v);
Obj_SetAngle(obj,dir);
ObjShot_SetGraphic(obj,graphic);
ObjShot_SetDelay(obj,0);
ObjShot_SetBombResist(obj,false);
 
while(!Obj_BeDeleted(obj)){
 
Obj_SetX(obj, x + 50*cos(90 + 6*t));
Obj_SetY(obj, y + 50*sin(90 + 6*t));
 
 
 
if(t==600-delay){
...


Little error on my side, since you actually want bullets to follow the same path, t has to start at 0 and end at 600-delay rather than to start at delay and end at 600.

Azure Lazuline

  • Looooove!!
  • PM me for free huggles and love!
    • Entanma Project - indie game development
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #417 on: July 10, 2011, 03:28:31 AM »
Why not explain the logic and how you came to that conclusion instead of just throwing code at him and expecting him to understand it? That would be a lot more helpful in the long run.

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #418 on: July 10, 2011, 11:29:38 AM »
Why not explain the logic and how you came to that conclusion instead of just throwing code at him and expecting him to understand it? That would be a lot more helpful in the long run.
Uh, I think I did.

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #419 on: July 10, 2011, 01:04:54 PM »
Uh, kinda just bumping my question since it seemed to be overlooked. Even if you don't know if it's possible, that's a better answer than no answer; at least then I'd know to move onto another language.

Hi, I was wondering if it was possible at all to implement a database of high scores?
I've been considering using Danmakufu as the coding language for my senior computer studies project, but a necessary feature is a high scores database.

Is it possible at all to write to a .txt file? I was thinking the final score would be written on a new line and then to display the top 10 scores, coding would find all the scores in the file, put them in descending order and then display the top 10.
Or is it possible to link in an SQL database (although I doubt this would be possible).