Go to page Previous  1 ... 3, 4, 5, 6, 7, 8, 9 ... 41  Next  [ 816 posts ]  Reply to topicPost new topic 
Coding Help, Questions and Issues relating to coding
Author Message
 [br]
 Post subject: Re: Coding Help
PostPosted: Fri Aug 02, 2013 6:16 pm 
User avatar
I Have Returned®
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
I'm having a problem with the cards system in my game, the problem is just the sprites. (GM)
So, this is what I needed:
- A Sprite with 10 images (blank cards) that are the same thing, it is the one shown in the game
- Another sprite with 10 different images for the collected cards
What I wanted to do is replace one image in the first sprite with the same image number in the second one.
For example, I have mario as the image 4, when I collect a card, Mario was chosen to be that card, he will replace image 4
in the first sprite as well (the blank card sprite)

Oh, and when you collect a card, the image selected is random, so that means you might get duplicates of the same card, I also have no idea on how would I make a system to count duplicate cards.

actually, for more information, you should play LEGO Island 2 for the GBC, which is where I'm basing the card system, it does exactly what I want to do, so you should play it to see how I want to make it work.

Hope I'm helped :P

_________________
 
Top
Offline 
 User page at mfgg.net
 
 [nl]
 Post subject: Re: Coding Help
PostPosted: Sun Aug 04, 2013 11:51 am 
User avatar
Wreck 'n get stomped
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
I hope this will fix it.

So, for example it chooses image_index = 3. Then, when the instance changes to the new object with the image. Something like this would work:

Syntax: [ Download ] [ Hide ]
Using gml Syntax Highlighting
//Any event which changes instance to the new card object
if image_index = 0 {global.cardindex = 0} //Or any other variable, as long as it's global
if image_index = 1 {global.cardindex = 1}
//etc
instance_change(obj_newcard,1); //Be sure this is placed AFTER the global.cardindex thing

//In the new card object's creation code
if global.cardindex = 0 {image_index = 0}
if global.cardindex = 1 {image_index = 1}
//etc


Hope this helped.

_________________
My Youtube | My Twitter
 
Top
Offline 
 User page at mfgg.net
 
 [us]
 Post subject: Re: Coding Help
PostPosted: Tue Aug 06, 2013 8:47 am 
User avatar
hi hello
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

Hey, I've been having problems coding something in MMF2 (hopefully some people still know how to use it). I want to create a text that scrolls in (like in PM and SMRPG). I found a fairly complex how-to on the main site, but I had no clue how to use it properly and I also got a glitch where the area of the speech bubble that the text overlaps just vanished as the text scrolled in.

I found a very simple way to do this which required only a few lines of code, but I ran into the same glitch. My question: Is there a (preferable simple) way to create scrolling text without having this annoying glitch, or do I actually have to animate a text (which would be a pain)?

Thanks very much in advance. And sorry if I sound stupid, I'm not a programming pro (at all).

_________________
What I support

Spoiler:
 
Top
Offline 
 User page at mfgg.net
 
 [us]
 Post subject: Re: Coding Help
PostPosted: Tue Aug 06, 2013 1:16 pm 
User avatar
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
lu9 wrote:
problem
Your description was pretty difficult to follow but I'll reread it and post a solution when I get on a computer. Try describing your problem once more, please.

 
Top
Offline 
 
 
 [ca]
 Post subject: Re: Coding Help
PostPosted: Tue Aug 06, 2013 4:57 pm 
User avatar
The Goomba Guy
Member
[*]
[*]
[*]
UEU Fangaming wrote:
Ok. Use creation codes like this:
Code:
varpath = path0

And add this to create event:
Code:
alarm[0] = 1

And add this to alarm 0:
Code:
path_start(varpath,2,blah,blah)

This makes using paths easier.
Also why I didn't using this?

Well I really dont like paths, I wanted line objects you can place in the level and have objects ride on them and fall whenever the line ends.

_________________
Image
 
Top
Offline 
 User page at mfgg.net
 
 [tr]
 Post subject: Re: Coding Help
PostPosted: Tue Aug 06, 2013 6:00 pm 
User avatar
Thanks DonnieTheGuy!
Administrator
[A]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
mario4513 wrote:
Well I really dont like paths, I wanted line objects you can place in the level and have objects ride on them and fall whenever the line ends.
Try using arrows. If the platform touches an arrow, it can change its direction.

_________________
Image
 
Top
Offline 
 
 
 [us]
 Post subject: Re: Coding Help
PostPosted: Tue Aug 06, 2013 6:56 pm 
User avatar
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
The 'arrow' object is a good idea mainly so you won't have multiple objects in the room. But if you do use the arrow idea then you want to make sure the platform changes it's direction relevant to a constant point of 'arrow' object.

 
Top
Offline 
 
 
 [br]
 Post subject: Re: Coding Help
PostPosted: Wed Aug 07, 2013 4:32 pm 
User avatar
I Have Returned®
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
Haha, take that!
By using 3 variables, I could make the card system 100% accurate to the one seem in LI2.
This code goes to the persistent object's creation code:
Syntax: [ Download ] [ Hide ]
Using gml Syntax Highlighting
//LI2 Cards System code - BY LU9
//global.card_numb = Number of the card being displayed on the screen
//global.card_duplicate = Number of duplicates of a card
//global.card_collected = If the player has collected that particular card already

//Set default card to view at the first time you go on the screen
global.card_numb = 1
//Resets all duplicates
global.card_duplicate[1] = 0
global.card_duplicate[2] = 0
global.card_duplicate[3] = 0
global.card_duplicate[4] = 0
global.card_duplicate[5] = 0
global.card_duplicate[6] = 0
global.card_duplicate[7] = 0
global.card_duplicate[8] = 0
global.card_duplicate[9] = 0
global.card_duplicate[10] = 0
//Set this so all cards are empty until you collect them.
global.card_collected[1] = false
global.card_collected[2] = false
global.card_collected[3] = false
global.card_collected[4] = false
global.card_collected[5] = false
global.card_collected[6] = false
global.card_collected[7] = false
global.card_collected[8] = false
global.card_duplicate[9] = false
global.card_duplicate[10] = false

Code for when the player gets the card:
Syntax: [ Download ] [ Hide ]
Using gml Syntax Highlighting
//Chooses a random card (this code is for normal cards, cards 1, 4, 6, and 8 are star cards)
global.card_numb = choose(2,3,5,7,9,10)
//Adds another to the number of duplicates of this card.
global.card_duplicate[global.card_numb] +=1
//If you already collected the card, it will show a different icon...
if global.card_collected[global.card_numb] = true
{
ID = instance_create(0,0,obj_cardget)
with (ID) image_index = 1
}
else
{
ID = instance_create(0,0,obj_cardget)
with (ID) image_index = 0
}
//Now you collected this card (if you haven't before)
if global.card_collected[global.card_numb] = false
{
global.card_collected[global.card_numb] = true
}
//Adds this object to the map of objects so it doesn't appear again once collected.
ds_map_add(global.cards,id,1)
//After all that, destroy.
instance_destroy()

And finally, the code for the card viewer, it is in the step command:
Syntax: [ Download ] [ Hide ]
Using gml Syntax Highlighting
//The player can view cards only from 1 to 10.
if global.card_numb = 0
global.card_numb = 10
else if global.card_numb = 11
global.card_numb = 1

//Displays the cards correctly
if global.card_numb = 1
{
sprite_index = [removed because it's a surprise :3]
    if global.card_collected[1] = true
    image_index = 1
    else
    image_index = 0
}
else if global.card_numb = 2
{
sprite_index = [removed because it'
s a surprise :3]
    if global.card_collected[2] = true
    image_index = 1
    else
    image_index = 0
}
else if global.card_numb = 3
{
sprite_index = [removed because it's a surprise :3]
    if global.card_collected[3] = true
    image_index = 1
    else
    image_index = 0
}
else if global.card_numb = 4
{
sprite_index = [removed because it'
s a surprise :3]
    if global.card_collected[4] = true
    image_index = 1
    else
    image_index = 0
}
else if global.card_numb = 5
{
sprite_index = [removed because it's a surprise :3]
    if global.card_collected[5] = true
    image_index = 1
    else
    image_index = 0
}
else if global.card_numb = 6
{
sprite_index = [removed because it'
s a surprise :3]
    if global.card_collected[6] = true
    image_index = 1
    else
    image_index = 0
}
else if global.card_numb = 7
{
sprite_index = [removed because it's a surprise :3]
    if global.card_collected[7] = true
    image_index = 1
    else
    image_index = 0
}
else if global.card_numb = 8
{
sprite_index = [removed because it'
s a surprise :3]
    if global.card_collected[8] = true
    image_index = 1
    else
    image_index = 0
}
else if global.card_numb = 9
{
sprite_index = [removed because it's a surprise :3]
    if global.card_collected[9] = true
    image_index = 1
    else
    image_index = 0
}
else if global.card_numb = 10
{
sprite_index = [removed because it'
s a surprise :3]
    if global.card_collected[10] = true
    image_index = 1
    else
    image_index = 0
}


That's it, if anyone wants to have a similiar trading cards system in your game you can use this code, as long as you give me credit :3

_________________
 
Top
Offline 
 User page at mfgg.net
 
 [nl]
 Post subject: Re: Coding Help
PostPosted: Wed Aug 07, 2013 4:39 pm 
User avatar
Wreck 'n get stomped
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
So I guess my code didn't work?

_________________
My Youtube | My Twitter
 
Top
Offline 
 User page at mfgg.net
 
 [tr]
 Post subject: Re: Coding Help
PostPosted: Wed Aug 07, 2013 5:39 pm 
User avatar
Thanks DonnieTheGuy!
Administrator
[A]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
Thats a very nice code but why you are using global.card_duplicate variable?
Also,
Spoiler:

_________________
Image
 
Top
Offline 
 
 
 [br]
 Post subject: Re: Coding Help
PostPosted: Wed Aug 07, 2013 5:59 pm 
User avatar
I Have Returned®
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
UEU Fangaming wrote:
Thats a very nice code but why you are using global.card_duplicate variable?

Because on Lego Island 2 for Gameboy Color you can collect duplicates of cards, and my card system is based on that, every time you collect a card, it is added to the number of duplicates of that card.
UEU Fangaming wrote:
lu9 wrote:
:3
Oh no! You are transforming into Dragezeey!

lolz, what's wrong into using this awesome smiley? OωO
lol

_________________
 
Top
Offline 
 User page at mfgg.net
 
 [tr]
 Post subject: Re: Coding Help
PostPosted: Wed Aug 07, 2013 6:28 pm 
User avatar
Thanks DonnieTheGuy!
Administrator
[A]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
lu9 wrote:
Because on Lego Island 2 for Gameboy Color you can collect duplicates of cards, and my card system is based on that, every time you collect a card, it is added to the number of duplicates of that card.
Ok ok. I understand.
lu9 wrote:
lolz, what's wrong into using this awesome smiley? OωO
lol
Because generally Drag uses this smiley. :3
:3 :3 :3

_________________
Image
 
Top
Offline 
 
 
 [gb]
 Post subject: Re: Coding Help
PostPosted: Wed Aug 07, 2013 7:17 pm 
I never really was on your side.
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
Does anybody off the top of their heads know how to check to see if a value is an integer?

 
Top
Offline 
 User page at mfgg.net
 
 [us]
 Post subject: Re: Coding Help
PostPosted: Wed Aug 07, 2013 7:28 pm 
User avatar
Lawful Evil
Member
[*]
[*]
[*]
[*]
[*]

[*]
if (floor(number) == number)
integer = true;

_________________
Image
Magikoopa Security Force, the Mario Action-Strategy game!
  It's time to fight for Bowser!
 
Top
Offline 
 User page at mfgg.net
 
 [us]
 Post subject: Re: Coding Help
PostPosted: Wed Aug 07, 2013 7:29 pm 
User avatar
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
I'm assuming you mean literally an integer and not a decimal number. Or are you saying if the value has a type value of integer and not string?

@magnemania: That will return true regardless of if it's a integer or decimal.

 
Top
Offline 
 
 
 [ca]
 Post subject: Re: Coding Help
PostPosted: Wed Aug 07, 2013 7:38 pm 
User avatar
The Quantifiably Quip-tic QC Dude
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
Try this.
Syntax: [ Download ] [ Hide ]
Using gml Syntax Highlighting
if ( number mod 1 == 0 ) //If you divide the number by 1, and there is no remainder...
{
    //The number is an integer.
}

_________________
<insert funny sig image here>

Image Refs - Something new's gonna show up here, I just know it! - DeviantArt - YouTubeImage
???!, 10%
 
Top
Offline 
 User page at mfgg.net
 
 [us]
 Post subject: Re: Coding Help
PostPosted: Wed Aug 07, 2013 7:41 pm 
User avatar
Lawful Evil
Member
[*]
[*]
[*]
[*]
[*]

[*]
kremling wrote:
@magnemania: That will return true regardless of if it's a integer or decimal.


Why? The floor of 1.1 is 1.1? Modulus with 1 is also going to work, but I don't see how floor() wouldn't.

_________________
Image
Magikoopa Security Force, the Mario Action-Strategy game!
  It's time to fight for Bowser!
 
Top
Offline 
 User page at mfgg.net
 
 [gb]
 Post subject: Re: Coding Help
PostPosted: Wed Aug 07, 2013 10:25 pm 
I never really was on your side.
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
Thank you, you guys, i got it working now.

 
Top
Offline 
 User page at mfgg.net
 
 [us]
 Post subject: Re: Coding Help
PostPosted: Sat Aug 10, 2013 1:25 pm 
User avatar
Always got a bone to pick
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
EDIT: Typed faster than I was thinking, confused myself.

_________________
Image

Image Image Image
 
Top
Offline 
 User page at mfgg.net
 
 [gb]
 Post subject: Re: Coding Help
PostPosted: Sat Aug 17, 2013 6:40 pm 
I never really was on your side.
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
Does anyone know of a way to make a tileset change it's blend/colour without having to create duplicates of the tileset? What I want is the tileset to change colour based on a certain condition, but I dont want to make 50 duplicates of it.

 
Top
Offline 
 User page at mfgg.net
 
« Previous topic | Next topic »
Display posts from previous:  Sort by  
Go to page Previous  1 ... 3, 4, 5, 6, 7, 8, 9 ... 41  Next  [ 816 posts ]  Reply to topicPost new topic 


Who is online

Users browsing this topic: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group