This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 »
901
Programming Help / Re: Question on variables and arrays (important)
« on: May 09, 2014, 11:11:23 pm »
I was talking about C++ since ENIGMA is a C++ engine and your project.
Yes I was aware that that when the array loses cope it is freed, in C++.
let's say I have Obj1 in LGM, in create event I declare a variable array a[100]. This is for obj1. Let's say obj1 is destroyed, does that mean the memory allocated to a[100] is freed with it?
I don't want to be in a situation where I make use of extensive arrays in a program, and that when the user exits the memory is still reserved, and re-run the program, new memory is allocated, whilst the old memory allocation is still active ,etc........eventually draining memory.
I don't know if this make sense, but don't see any other way of explaining it.
Yes I was aware that that when the array loses cope it is freed, in C++.
let's say I have Obj1 in LGM, in create event I declare a variable array a[100]. This is for obj1. Let's say obj1 is destroyed, does that mean the memory allocated to a[100] is freed with it?
I don't want to be in a situation where I make use of extensive arrays in a program, and that when the user exits the memory is still reserved, and re-run the program, new memory is allocated, whilst the old memory allocation is still active ,etc........eventually draining memory.
I don't know if this make sense, but don't see any other way of explaining it.
902
Programming Help / Question on variables and arrays (important)
« on: May 09, 2014, 06:40:09 pm »
Ok now I understand all about variable types and how one must declare variables and the different ways to do so.
I also know that variables take memory and by declaring them it reserves memory for them at runtime right ?
Example
int a[100]
Would initialize an array of a with 99 blocks contiguous memory allocations right?
My questions are as follows.
Now this would be a static array if not mistaken.
1. What if I don't know in advance the size of my array and would like to leave it dynamic how would I go about?
2. Let's say I do not need the array anymore but want to free the memory used of a[0] to a[99] (the array I declared), how would I do this ?
3. IS it necessary to manually free all variable and arrays before my program exits or is it done automatically ?
I also know that variables take memory and by declaring them it reserves memory for them at runtime right ?
Example
int a[100]
Would initialize an array of a with 99 blocks contiguous memory allocations right?
My questions are as follows.
Now this would be a static array if not mistaken.
1. What if I don't know in advance the size of my array and would like to leave it dynamic how would I go about?
2. Let's say I do not need the array anymore but want to free the memory used of a[0] to a[99] (the array I declared), how would I do this ?
3. IS it necessary to manually free all variable and arrays before my program exits or is it done automatically ?
903
Issues Help Desk / Blend mode not working in DX9
« on: May 09, 2014, 01:10:14 am »
I have this code in draw event
in create I have set variable r=100 and m to 1.
This sets the default radius to 100 and alpha to 1.
Through a step event I control the alpha and radius using keyboard.
This worked fine in OGL1, OGL3, in DX9, the glow light circle does not show at all.
If I were to use
draw_circle_color(mouse_x, mouse_y, r, c_white, c_black, 0);
without the blend modes,
that would work in DX9, and display a white to black gradiant circle as it should.
So blend mode does not work in DX9 in ENIGMA.
Is this normal?
Code: [Select]
draw_set_blend_mode( bm_add );
draw_set_alpha(m);
draw_circle_color(mouse_x, mouse_y, r, c_white, c_black, 0);
draw_set_blend_mode( bm_normal );
draw_set_alpha(1);
draw_text(10,10,"Alpha: "+string(m));
draw_text(10,20,"Radius: "+string(r));
in create I have set variable r=100 and m to 1.
This sets the default radius to 100 and alpha to 1.
Through a step event I control the alpha and radius using keyboard.
This worked fine in OGL1, OGL3, in DX9, the glow light circle does not show at all.
If I were to use
draw_circle_color(mouse_x, mouse_y, r, c_white, c_black, 0);
without the blend modes,
that would work in DX9, and display a white to black gradiant circle as it should.
So blend mode does not work in DX9 in ENIGMA.
Is this normal?
904
Programming Help / Re: Very hard time with ENIGMA (while, for, until, etc.)
« on: May 08, 2014, 03:50:42 am »
Very interesting thanks
Yes indeed placing it in create worked.
BTW, what function do I use to find out the length
of an array?
example
This is in create event.
Let's say I want to find length of the array word,
in this example it should return me a 9.
array_length_1d compiles with error function not found, even though the command is highlighted and documented.
Yes indeed placing it in create worked.
BTW, what function do I use to find out the length
of an array?
example
Code: [Select]
{
i=0;
word=0;
for (i=0; i < 10; i++)
{
word[i]="Count: "+string(i);
}
}
This is in create event.
Let's say I want to find length of the array word,
in this example it should return me a 9.
array_length_1d compiles with error function not found, even though the command is highlighted and documented.
905
Graphics and Video / Re: Artwork
« on: May 08, 2014, 12:11:51 am »Yes, TKG do it, make us Snake Penis HD !!! I will play it.
So boring........ I have a better idea.
Snake with a Pink Penis HD
906
Graphics and Video / Re: Artwork
« on: May 07, 2014, 10:54:04 pm »Lol, I was thinking of a snake/dragon penis.
LOL.
Guess now we have clues as to what his new game will be !
BTW TKG, the removing textures I do a lot, using highlight and shadow tools in photoshop
However, I've never done the shading thing, I really like the adding textury look to the design as opposed to flat colors, which most people do in GM games
Nice.
So what's going to be your next game ?
Revenge of Snake Penises ?
I totally suck balls at making sprite characters for my games, would you mind helping me with sprites for my future platform games ?
907
Programming Help / Re: Very hard time with ENIGMA (while, for, until, etc.)
« on: May 07, 2014, 09:04:24 pm »
Ok, experimented a bit and done it. For something that needs to be done incrementally step by step, I need to do it this way, for something that needs complete execution of a loop inside 1 step, I would use for loops.
So here, this would work instead of what I wrote above this post:
and inside draw event
This works !
I even added a debug for variable i and variable key,
it works as it should. When key up is pressed key = 1, whenever key =1 it ignores vk_up, until execution of key =1 code is done, then it resets i and key.
I used a draw event and I can see the counter incrementing every step.
Is it correct what I did above ? Is the coding clean
or is there a better way to do the above?
Is there any use of while / do / until in code above as I tried it and it did not work at all.
Now, I applied what I learned in how for loop works in other languages and done something with arrays.
Now here is some new experiment I've done with for loops successfully.
in Create code
In Step code
So array creation will only occur once when this object is created.
In draw event
Result:
Count: 0
Count: 1
Count: 2
Count: 3
Count: 4
Count: 5
Count: 6
Count: 7
Count: 8
Count: 9
Count: 10
-------------
Success! Now the while / do / until for another day.
So here, this would work instead of what I wrote above this post:
Code: [Select]
if (key = 0)
{
if keyboard_check_pressed(vk_up)
{
key = 1;
}
}
if (key = 1)
{
i++
if (i < 11)
{
x=random(room_width);
y=random(room_height);
}
else
{
i = 0;
key = 0;
}
}
and inside draw event
Code: [Select]
draw_text(10,10,"Key: "+string(key));
draw_text(10,20,"i: "+string(i));
draw_self();
This works !
I even added a debug for variable i and variable key,
it works as it should. When key up is pressed key = 1, whenever key =1 it ignores vk_up, until execution of key =1 code is done, then it resets i and key.
I used a draw event and I can see the counter incrementing every step.
Is it correct what I did above ? Is the coding clean
or is there a better way to do the above?
Is there any use of while / do / until in code above as I tried it and it did not work at all.
Now, I applied what I learned in how for loop works in other languages and done something with arrays.
Now here is some new experiment I've done with for loops successfully.
in Create code
Code: [Select]
word = 0;
firstrun = 1;
i = 0;
In Step code
Code: [Select]
if (firstrun = 1)
{
for (i=0; i < 11; i++)
{
word[i]="Count: "+string(i);
}
firstrun = 0;
i = 0;
}
So array creation will only occur once when this object is created.
In draw event
Code: [Select]
for (i = 0; i < 11; i++)
{
draw_text(10,(10*i),word[i]);
}
Result:
Count: 0
Count: 1
Count: 2
Count: 3
Count: 4
Count: 5
Count: 6
Count: 7
Count: 8
Count: 9
Count: 10
-------------
Success! Now the while / do / until for another day.
908
Programming Help / Re: Very hard time with ENIGMA (while, for, until, etc.)
« on: May 07, 2014, 08:50:48 pm »
Yes now that I see it visually it makes sense that the FOR would execute completely each step as opposed to incrementally. Understood, so in this case I should increment the value of variables myself outside of a loop. So in which cases then would a for loop be properly used in a step event ? Also I can't get while, do until to work at all. Even without for / loops. and most of the code in games are done in step events.
So it's hard for me. I'd have to create tons of control objects to do individual tasks instead of being able to put every thing inside a step event in my main controller.
Here is an example experiment, let's say I want to check if key up is PRESSED, if it is then object's x
and y positions would change to a random value 10 times and then wait. Whilst this is happening, having the feature of ignoring the key check since it is being processed ......
This would obviously not work and I know why:
if keyboard_check_pressed(vk_up)
{
key = 1;
}
if (key = 1)
{
repeat (10); {
x=random(room_width);
y=random(room_height); }
}
key=0
So how would I be able to make this work ?
Refer to post below this one, I figured it out.
An alternative would be to set a controller object
and increment a variable manually with an if
and create instance of other object and destroying itself. and calling this controller through instance create. that's why I was wondering I can do all this in a single step event of the instance object.
So it's hard for me. I'd have to create tons of control objects to do individual tasks instead of being able to put every thing inside a step event in my main controller.
Here is an example experiment, let's say I want to check if key up is PRESSED, if it is then object's x
and y positions would change to a random value 10 times and then wait. Whilst this is happening, having the feature of ignoring the key check since it is being processed ......
This would obviously not work and I know why:
if keyboard_check_pressed(vk_up)
{
key = 1;
}
if (key = 1)
{
repeat (10); {
x=random(room_width);
y=random(room_height); }
}
key=0
Refer to post below this one, I figured it out.
An alternative would be to set a controller object
and increment a variable manually with an if
and create instance of other object and destroying itself. and calling this controller through instance create. that's why I was wondering I can do all this in a single step event of the instance object.
909
Issues Help Desk / Re: User events not working.
« on: May 07, 2014, 08:32:12 pm »Yes and no, we have event_perform and we are aware it does not work on user defined events yet, just use the other function for now.
Don't go filing an issue because we already have a ticket on it.
https://github.com/enigma-dev/enigma-dev/issues/99
Ok no problem tried using the event_user and it worked.
@TKG: event perform is documented on GMS and is not marked as obsolete. What is obsolete is user event triggers.
910
Issues Help Desk / Re: User events not working.
« on: May 07, 2014, 08:02:36 pm »Use event_user(NUMBER); to call the user event. Just tested and it works calling it this way.
ok will do thanks It's also documented in GMS.
BTW, just to make it clear, I am just experimenting with things, want to cover different features. I understand about the steps, and repeat / for / while ,etc not being incremental every step but executing the bulk each step and so I have to use variables and do things manually for them to be processed each step.
Now as far as user events where you could place actions inside them. Is it best practice to create controller objects instead and and call them through instance create or use user events ?
911
Issues Help Desk / User events not working.
« on: May 07, 2014, 07:21:53 pm »
Before someone asks me to read docs, I did. This is definition of user events as per GMS:
So, from what I understand, these events called by the running game can include blocks of code.
I created a user defined 0 event, in which I placed
code game_end();
Inside the object's step event I check for keyboard
up key and execute the event user defined 0, which
should end game right ?
Does not work, nothing happens.
I even tried commenting out the if, just for testing purposes and nothing happens.
Mind you this is just out of curiosity, as I would probably use control objects if need be. but I would like to know why this does not work.
Quote
User Defined Event
These are special events that are not triggered by GameMaker: Studio itself, but have to be implicitly called by you from a code box while the game is running. These events can contain code or actions and do the same things as any other event, making them very useful for creating your own events that happen when you decide and not GameMaker: Studio decides!
So, from what I understand, these events called by the running game can include blocks of code.
I created a user defined 0 event, in which I placed
code game_end();
Inside the object's step event I check for keyboard
up key and execute the event user defined 0, which
should end game right ?
Code: [Select]
// in step event
if keyboard_check_direct(vk_up)
{
event_perform(ev_user0,0);
}
Does not work, nothing happens.
I even tried commenting out the if, just for testing purposes and nothing happens.
Mind you this is just out of curiosity, as I would probably use control objects if need be. but I would like to know why this does not work.
912
Off-Topic / Re: The choice was obvious, and it wasn't Enigma
« on: May 07, 2014, 05:59:25 pm »Quote from: time-killer-games link=topic=1919.msg18713#msg18713
date=1399497426Three words...
GOOGLE DRIVE
But I'm only seeing two!
LOL!
913
Programming Help / Re: Very hard time with ENIGMA (while, for, until, etc.)
« on: May 07, 2014, 05:54:41 pm »If you mean like Visual Basic, their For-Loops are fucked up and way different from what ENIGMA does.
No TKG I did not mean visual basic, never used it and never will. I am talking about good old fashioned basic lol. I then used some powerbasic, but most of what I used was standard BASIC and QBASIC. Yes I am aware now that for loops are quite different in C++, and yes there are no NEXT all that is handled in the same line with for.
Quote
Again, ENIGMA is derived from C++ and the closely related syntax of GML. Basic is a different animal.
Understood, but I saw some C++ examples where a message is printed in a foor loop,
such as couting 100 times hello world for example,
done in a for loop.
Quote
Read the YYG docs (in GMS press the F1 key + search "for"). You can achieve exactly what you want with a C++/GML syntax'd for loop but it's done a bit different.
I access the docs through docs.yoyogames.com
and I read them frequently. I know far more GML now and enough to make a platform game, but
now I am stuck in a loop with the for while until do shit
Quote
// Note that it will draw to the game's window instead of being printed to the compile form...
for (i=0; i<=100 i+=1) {
draw_text(0,0,string(i))
}
That's not right either TKG.
Looks like for what I wanted to do I will have to do it differently,
here is a method that does work:
create event
i=0
draw event
Code: [Select]
{
if i < 100
{
draw_text(10,10,"Count: "+string(i++));
}
else
draw_text(10,10,"Count: "+string(i));
}
This increments 1 each step, and at 100 stops and continues displaying 100.
I guess I have to do it this way for everything I guess.
I was just curious as to why it did not work with for as it did in basic.
Guess I know now, the entire loop is done in 1 step and not broken down into 100 steps whereas doing things as above, it is incremented every step.
914
Programming Help / Re: Very hard time with ENIGMA (while, for, until, etc.)
« on: May 07, 2014, 05:42:29 pm »It's not odd at all. A for loop repeats the code inside it until a condition is met (http://en.wikipedia.org/wiki/For_loop). In this case that means drawing 100 times (numbers from 0 to 99) in one step.
But the reason for the loop in my example was
to repeat code until the condition of i=100 is met.
I have seen maybe print counter examples done with for/loop this way, that's why I am confused.
Quote
I think you don't really understand how cycles work. Or how steps work. The code you put in events like draw or step are executed once every frame (called step in GM).
I knew that and understand how it works and am aware 1 frame = 1 step, and the draw/step is executed at room speed, by default 30 steps per second.
And I know what create events are, I use those to initialize variables and set my object's settings upon create.
Quote
codes you posted work just fine. They would work like that in GM, ENIGMA, C++, Basic, Python or anywhere else.
You are wrong about BASIC Harri You have no idea how much I used loops when I used BASICS,
it was abused lol and I already gave you an example of a BASIC loop. But in BASIC there are no draw events, create events, step, begin and end step events shit works differently now apparently
and I am seriously fucked, unless I know how things are to be done now.
Quote
It works just like you coded it. There are no bugs or problems with while, for or repeat cycles.
If it worked I would not be posting this. I am working based on the logic of what I need done.
perhaps a better way for me is to simply say what I need done and then someone recommends me code on how to do it I am pretty sure some of the stuff is broken in ENIGMA, because I don't always get the same outcome when running / compiling games ...
here is an example, let's say I want to read from
a file, start pos to end pos, i BASIC I used for loop for that and used the loop's for variable in the code between the for and next. I saw some C++ programs do this, so why can't I do it here?
Quote
No it shouldn't. As I mentioned before Draw event (the one actually drawing to the screen) is executed once per frame. While the for(){} you have created here executes 100 times per frame. So when using that loop you should see the object at x=100 in every frame.
Understood. So, in this example, how can I make an object move 100 pixels (1 pixel at a time) using a for / loop then ?
I thought that in each step the i would increment 1. I could have sworn seeing for loops in step events before, how can that be then ?
Quote
Read up on loops. You said you used Basic before, I think they had loops too.
On an expert level yes I used BASIC and I can swear on my life that it worked differently.
Quote
execute it every step from the beginning. You cannot have one script execute spanning multiple steps. Like this is impossible:
So what is the alternative then, incrementing the value of i myself, but then I would have to use do until or while, and that does not work either...
When reading docs in enigma and GMS I see for loops being used, when I apply the examples they don't work.
915
Programming Help / Re: Very hard time with ENIGMA (while, for, until, etc.)
« on: May 07, 2014, 04:22:08 pm »
Maybe I am not explaining myself correctly or what I want to do, but I will use an example I would do in BASIC, that would work. Yes obviously things work and execute differently but this is just as an example
In this case the code is executed between the FOR and NEXT inside a LOOP. The loop starts with variable I set to 0 and increments by 1, the printing will take whatever value is in I and print it sequentially across the screen. That's how it worked in BASIC. You didn't have step events, draw events, etc. I guess maybe I have to do things differently now, but I tried with other methods that not involve for / loop and variable values were all over the place!
FOR I=0 TO 100 STEP 1
PRINT I
NEXT I
In this example you would see numbers from 0 to 100
printed, as print is taking the value of I. I will not argue here, I used BASIC on an expert level and made complex apps and games back in the days using a combination of BASIC/ASM or native ASM, and it worked fine.
In this case the code is executed between the FOR and NEXT inside a LOOP. The loop starts with variable I set to 0 and increments by 1, the printing will take whatever value is in I and print it sequentially across the screen. That's how it worked in BASIC. You didn't have step events, draw events, etc. I guess maybe I have to do things differently now, but I tried with other methods that not involve for / loop and variable values were all over the place!
FOR I=0 TO 100 STEP 1
PRINT I
NEXT I
In this example you would see numbers from 0 to 100
printed, as print is taking the value of I. I will not argue here, I used BASIC on an expert level and made complex apps and games back in the days using a combination of BASIC/ASM or native ASM, and it worked fine.