Author Topic: Game Design Megathread  (Read 555159 times)

For reference, here's a dialog class I coded a while ago for a game I was working on.

How it works is you would create the class, and use the function :setLines(messages) and give it a table of messages all in one go, which would be the screens of dialog for whatever character was talking. The class keeps track of its current message, and uses the function :advance() to move on to the next message. To simplify it:

Dialog = {
   lines = {},
   current = 1,
   active = false,
}

function Dialog:setLines(lines)
   -- should be self-explanatory
   self.lines = lines
end

function Dialog:advance()
   -- advance to the next message
   self.current = self.current + 1

   -- return true if we have no messages, false otherwise
   if self.current > #self.lines then
      return true
   end
   return false
end

function Dialog:draw()
   if self.active then
      local message = self.lines[self.current] -- get the current message
      if message then -- check to make sure it exists
         love.graphics.print(message, 10, 10) -- draw it
      end
   end
end


Usage:

function love.load()
   -- 'open' the dialog with these messages
   Dialog:setLines{ 'Hello world', 'These are some', 'Dialog messages' }
   Dialog.active = true
end

function love.keypressed(k)
   -- advance the dialog when spacebar is pressed
   if k == ' ' then
      local done = Dialog:advance()
      if done then -- :advance() will return true if we're done, so we check
         Dialog.active = false -- and hide the dialog if it returned true
      end
   end
end

function love.draw()
   Dialog:draw()
end


That's all that's important. The functions :show() and :hide() in the code I linked do as they say, and the :update(dt) function is just used to make a nice typewriter effect, but is unessential.

-snipz-

awesome thanks
i just knew there was going to be a way easier way and i was just over-complicating things lol

Can someone help me with something GameMaker Related in this thread? Just wondering, and curious.

well if you don't actually mention the problem we won't know if we can help you or not

Can someone help me with something GameMaker Related in this thread? Just wondering, and curious.

What do you need?

well if you don't actually mention the problem we won't know if we can help you or not
What do you need?
Well for now I just wanted to know. I wasn't really sure if this was a thread just for games using certain programs or not.

I'm working on making a Megaman X fan game, and it uses my favorite bosses throughout the sprite-like series (X1 - X6). I've got really great progress on it too besides coding bosses. I'm working on getting the attacks in for Izzy Glow from Megaman X5. I wanted to start by at random times shooting the Firefly Laser that X can receive for a weapon. I got it so the missile (Or Firefly laser) can track X and destroy itself if it gets to X or hits a wall. However I'm having trouble getting the trail (the circles following the f-laser) following the f-laser without screwing up the way the missile looks with it. I'm trying to make both the F-laser and it's trail the way you see in fights against Izzy glow himself. Like when he shoots one in the first place, the trail follows the f-laser. Thus it's like the trail is following the same path as the f-laser without changing direction heading towards X (Getting my logic so far? It's tricky to explain for me).




This is the Firefly Laser Missle

Here's the coding and events for the Firefly laser I have so far. In the step event, it's pretty good tracking X without doing some pathfinding. I'm working on making it so it can go around walls and find X. Which is obj_FAX (FAX meaning Falcon Armor X).

Create Event
Code: [Select]
audio_play_sound(snd_FireFly_Laser,1,false);
if (image_angle= 0)
{
 Direction = 1;
}
else
{
 Direction = 3;
}
First it will play the shooting sound of the Firefly laser. Then it depends on the angle of the image that Direction will be. If the missile is facing left, Direction is 3. If it's facing right, then Direction is 1. Direction being 2 or 4 means that the missile is either up or down. I don't think I was using Direction at the moment since I'm trying to find a way to make all of this work.

Destroy Event
It just creates an explosion object, and sets the sprite index and custom variable "Missile" on Izzy glow. I used blocks instead of execute code blocks for this because it was pretty easy, and I had to apply different blocks on different objects.

Step Event

Collision Script
Code: [Select]
///Collisions

if place_meeting(x,y,floorctrl)
{
 instance_destroy();
}
if place_meeting(x,y,obj_NAX)
{
 instance_destroy();
}
if place_meeting(x,y,obj_FAX)
{
 instance_destroy();
}
NAX = No Armor X FAX = Falcon Armor X floorctrl is basically an object that controls any stage collsion objects (walls, etc.).

Targeting FAX (I'm using FAX for now in the test room. I'm only worrying about this code, and then gonna copy and paste for NAX).
Code: [Select]
///Targeting FAX

if instance_exists(obj_FAX)
{
 //Missle Rotation
 if (x)
 {
  if (x > obj_FAX.x)
  {
   image_angle = 0;
  }
  if (x < obj_FAX.x)
  {
   image_angle = 180;
  } 
 }
 if (x = obj_FAX.x) and (y)
 {
  if (y < obj_FAX.y)
  {
   image_angle = 90;
  }
  if (y > obj_FAX.y)
  {
   image_angle = -90;
  }
 }
 
 //Missle Movement to FAX
 if (y != obj_FAX.y) and (x != obj_FAX.x)
 {
  mp_linear_step_object(obj_FAX.x,y,1,floorctrl);
 }
 if (y!=obj_FAX.y) and (x=obj_FAX.x)
 {
  mp_linear_step_object(x,obj_FAX.y,1,floorctrl);
 }
 
 if (!place_free(x-5,y))
 {
  x+=1
  if y < obj_FAX.y
  {
   image_angle = 90;
   mp_linear_step(x+1,obj_FAX.y,1,false);
  }
  if y > obj_FAX.y
  {
   image_angle = -90;
   mp_linear_step(x+1,obj_FAX.y,1,false);
  }
 }
}




And here's the trails, image_index does change randomly as seen in the bottom code.

And now for the missile trail coding. I have two trails for this: One big, and one small. The big trail copys everything the small trail would do, but it has a mask that is for the small trail.
Create Event
Code: [Select]
///Variable Initialization
if instance_exists(obj_Izzy_Missle)
{
 Distance = (obj_Izzy_Missle.x + obj_Izzy_Missle.y) - (x + y);
}
Basically saying that if the F-laser missile exists, then distance will equal how far the missle is away from the trail object itself.

Step Event

Line 1
Code: [Select]
image_index = round(random(6));

if instance_exists(obj_Izzy_Missle)
{
 if (y=obj_Izzy_Missle.y)
 {
  if (x > obj_Izzy_Missle.x)
  {
   mp_linear_step(obj_Izzy_Missle.x+Distance,y,1,false);
  }
  if (x < obj_Izzy_Missle.x)
  {
   mp_linear_step(obj_Izzy_Missle.x-Distance,y,1,false);
  }
 }
 if (y!=obj_Izzy_Missle.y)
 {
  if (x > obj_Izzy_Missle.x)
  {
   mp_linear_step(obj_Izzy_Missle.x,y,1,false);
  }
  if (x < obj_Izzy_Missle.x)
  {
   mp_linear_step(obj_Izzy_Missle.x,y,1,false);
  }
 }
 if (x=obj_Izzy_Missle.x)
 {
  if (y!=obj_Izzy_Missle.y)
  {
   if (y < obj_Izzy_Missle.y)
   {
    mp_linear_step(x,obj_Izzy_Missle.y-Distance,1,false);
   }
   if (y > obj_Izzy_Missle.y)
   {
    mp_linear_step(x,obj_Izzy_Missle.y+Distance,1,false);
   }
  }
 }
 if (y=obj_Izzy_Missle.y)
 {
  if(x!=obj_Izzy_Missle.x)
  {
   if (x < obj_Izzy_Missle.x)
   {
    mp_linear_step(obj_Izzy_Missle.x+Distance,y,1,false);
   }
   if (x > obj_Izzy_Missle.x)
   {
    mp_linear_step(obj_Izzy_Missle.x-Distance,y,1,false);
   }
  }
 }
}
else
{
 if instance_exists(obj_FAX)
 {
  mp_linear_step(obj_FAX.x,obj_FAX.y,1,false);
 }
 if instance_exists(obj_NAX)
 {
  mp_linear_step(obj_FAX.x,obj_FAX.y,1,false);
 }
}
This is basically what it takes to find Izzy's missile. It works "OK", but I want to improve it somehow. When the missile is destroyed however, it will head towards Megaman X and destroy itself when it gets there.

Line 2: Collisions
Code: [Select]
if place_meeting(x,y,obj_FAX) or place_meeting(x,y,obj_NAX)
{
 instance_destroy();
}
The code is self explanatory.

what is the point of indenting if it's gonna be so tiny

what is the point of indenting if it's gonna be so tiny
Because it's polite and the usual coding etiquette to properly indent.

He means why the tabbing is so small, and I agree. 2 spaces or more would be nice, otherwise there's not much of a point.

He means why the tabbing is so small, and I agree. 2 spaces or more would be nice, otherwise there's not much of a point.
Ah, thought he was talking about font size.

I usually use 4 spaces per tab.

what is the point of indenting if it's gonna be so tiny
He means why the tabbing is so small, and I agree. 2 spaces or more would be nice, otherwise there's not much of a point.
I just copied and paste the code. Also used [ code ] tags too. That's all I did.

jesus christ



p.s. I did not make that model

this was the error message UE4 gave me when I built the lighting but idk what any of it means lol
http://i.imgur.com/LRUfsnU.png

what's weird is that it actually looks kinda decent before I build the lighting



here's what the model look's like in Blender



also the texture being missing in UE4 isn't a real issue. I just forgot to check something when I imported it
« Last Edit: September 15, 2014, 02:56:30 AM by Foxscotch »

Your UV maps are screwed up not necessarily correct, and if you don't fix this it could mess with lighting and texturing. In your modeling program, go to the UV mapper and look to see if there are any triangles/polys that are overlapping the same space, and then separate them.

EDIT: An importance volume is pretty simple, it's just another object like a player spawn which tells the game what it should light first IIRC. It's kind of like the killzone. Just set it in some place and don't worry about it, since it really only affects really big projects.
« Last Edit: September 15, 2014, 03:09:40 AM by McJobless »

Your UV maps are screwed up not necessarily correct, and if you don't fix this it could mess with lighting and texturing. In your modeling program, go to the UV mapper and look to see if there are any triangles/polys that are overlapping the same space, and then separate them.
this?



I don't see anything that looks unusual

That's a texture map. That's the actual colours themselves. What you want is the UV map.

You need to open up the model file inside something like Maya or Blender, or if it's just an .obj, you can download the free UV program called "Roadkill". Then you need to check your to see if any polygons are overlapping, and make sure that all your polygons fit within the 0, 1 space.

This is an example of a good UV map:



A UV, to explain basically what it is, is like you are taking the wireframe of your model, and then you're cutting it into little pieces so that you can texture it properly. Video Game tech is only just getting ready to use 3D scultping tools. UV mapping is an old technique when you couldn't just directly paint on your model.

Also, be thankful you're using Unreal 4. UDK also required lightmaps (as well as the normal UV maps), which were very strict UV maps that would take hours to get right, and controlled how static light and shadows affected the model. Unreal 4 now properly handles dynamic lighting, so you only have to deal with your UV maps/texture maps.

EDIT: To explain why UV overlapping is a bad idea, let's say you make your UV map and two polys have the same space. Now, if they both had to be black, that would be completely fine, and they'd both turn out black. But what if one needs to be red, and one needs to be blue? Both polygons would be whatever colour you paint in that space in the texture map.

You can usually get away with it just fine, but most professional studios request that you have clean, non-overlapping UVs so that they change the texture at any time without encountering any issues.

Also, I think that Unreal might be using the texture UVs to generate some of the lighting stuff, which is why it might be complaining.
« Last Edit: September 15, 2014, 03:32:33 AM by McJobless »