2 Questions on SDL...
Moderator: Coders of Rage
- ibly31
- Chaos Rift Junior
- Posts: 312
- Joined: Thu Feb 19, 2009 8:47 pm
- Current Project: Like... seven different ones
- Favorite Gaming Platforms: Xbox 360, Gamecube
- Programming Language of Choice: C++, ObjC
- Location: New Jersey.
2 Questions on SDL...
One: How do you change the cursor from that odd inverted black one that it makes you have?
Two: How do you get keys to repeat? My keys are like... semiautomatic, one event per press, instead of auto, one press, as many events as you want until you let go. Hold down any key while in a text box, you see how it goes ssssssssssssssssssss? Instead of just s? How do you do this in SDL?
Two: How do you get keys to repeat? My keys are like... semiautomatic, one event per press, instead of auto, one press, as many events as you want until you let go. Hold down any key while in a text box, you see how it goes ssssssssssssssssssss? Instead of just s? How do you do this in SDL?
Website/Tumblr
My Projects
The best thing about UDP jokes is that I don’t care if you get them or not.
- wtetzner
- Chaos Rift Regular
- Posts: 159
- Joined: Wed Feb 18, 2009 6:43 pm
- Current Project: waterbear, GBA game + editor
- Favorite Gaming Platforms: Game Boy Advance
- Programming Language of Choice: OCaml
- Location: TX
- Contact:
Re: 2 Questions on SDL...
Instead of using events, use the keystate array in your main loop.
http://www.lazyfoo.net/SDL_tutorials/lesson10/index.php
http://www.lazyfoo.net/SDL_tutorials/lesson10/index.php
The novice realizes that the difference between code and data is trivial. The expert realizes that all code is data. And the true master realizes that all data is code.
- programmerinprogress
- Chaos Rift Devotee
- Posts: 632
- Joined: Wed Oct 29, 2008 7:31 am
- Current Project: some crazy stuff, i'll tell soon :-)
- Favorite Gaming Platforms: PC
- Programming Language of Choice: C++!
- Location: The UK
- Contact:
Re: 2 Questions on SDL...
You could track the cursor, and then blit your own cursor image to the cursor location (and hide the actual cursor).ibly31 wrote:One: How do you change the cursor from that odd inverted black one that it makes you have?
I do that a lot when i'm trying out new features with editors.
---------------------------------------------------------------------------------------
I think I can program pretty well, it's my compiler that needs convincing!
---------------------------------------------------------------------------------------
And now a joke to lighten to mood :D
I wander what programming language anakin skywalker used to program C3-PO's AI back on tatooine? my guess is Jawa :P
I think I can program pretty well, it's my compiler that needs convincing!
---------------------------------------------------------------------------------------
And now a joke to lighten to mood :D
I wander what programming language anakin skywalker used to program C3-PO's AI back on tatooine? my guess is Jawa :P
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: 2 Questions on SDL...
http://www.google.com/search?hl=en&q=sd ... h&aq=f&oq=
http://ubuntuforums.org/showthread.php?t=500717
http://ubuntuforums.org/showthread.php?t=500717
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
- ibly31
- Chaos Rift Junior
- Posts: 312
- Joined: Thu Feb 19, 2009 8:47 pm
- Current Project: Like... seven different ones
- Favorite Gaming Platforms: Xbox 360, Gamecube
- Programming Language of Choice: C++, ObjC
- Location: New Jersey.
Re: 2 Questions on SDL...
So, how do I know which key is which in the array? Is there a specific list?
So if I'm checking for up, and its 3rd in the list, would i do *psuedo code*
if(keystatearray[3] == 1){
movecharacterup();
}
So if I'm checking for up, and its 3rd in the list, would i do *psuedo code*
if(keystatearray[3] == 1){
movecharacterup();
}
Website/Tumblr
My Projects
The best thing about UDP jokes is that I don’t care if you get them or not.
- Kros
- Chaos Rift Regular
- Posts: 136
- Joined: Tue Feb 24, 2009 4:01 pm
- Current Project: N/A
- Favorite Gaming Platforms: PC, Playstation/2/3
- Programming Language of Choice: C++
- Location: Oregon,USA
- Contact:
Re: 2 Questions on SDL...
I highly recommend looking through this page:
http://www.libsdl.org/cgi/docwiki.cgi/SDL_API
And to specifically answer your second question:
http://www.libsdl.org/cgi/docwiki.cgi/S ... eKeyRepeat
http://www.libsdl.org/cgi/docwiki.cgi/SDL_API
And to specifically answer your second question:
http://www.libsdl.org/cgi/docwiki.cgi/S ... eKeyRepeat
YouTube ChannelIsaac Asimov wrote:Part of the inhumanity of the computer is that, once it is competently programmed and working smoothly, it is completely honest.
- ibly31
- Chaos Rift Junior
- Posts: 312
- Joined: Thu Feb 19, 2009 8:47 pm
- Current Project: Like... seven different ones
- Favorite Gaming Platforms: Xbox 360, Gamecube
- Programming Language of Choice: C++, ObjC
- Location: New Jersey.
Re: 2 Questions on SDL...
RANDOMERRORWTF?!?!?!
Okay... this is really f***ing gay.
THIS code works:
But this doesn't:
I did this, because I realized that it would do (0*0,0*1,0*2,0*3,1*0,1*1,1*2,1*3,etc...), instead of what I wanted, just a straight value that increments. Really, wtf is wrong with this?!?
Okay... this is really f***ing gay.
THIS code works:
Code: Select all
void initClips(){
for(int y = 0; y <=11; y++){
for(int x = 0; x <= 3; x++){
clip[x*y].h = 32;
clip[x*y].w = 32;
clip[x*y].x = x*32;
clip[x*y].y = y*32;
}
}
}
Code: Select all
void initClips(){
int val = 0;
for(int y = 0; y <=11; y++){
for(int x = 0; x <= 3; x++){
clip[val].h = 32;
clip[val].w = 32;
clip[val].x = x*32;
clip[val].y = y*32;
val++;
}
}
}
Last edited by ibly31 on Wed Mar 11, 2009 7:06 pm, edited 1 time in total.
Website/Tumblr
My Projects
The best thing about UDP jokes is that I don’t care if you get them or not.
- M_D_K
- Chaos Rift Demigod
- Posts: 1087
- Joined: Tue Oct 28, 2008 10:33 am
- Favorite Gaming Platforms: PC
- Programming Language of Choice: C/++
- Location: UK
Re: 2 Questions on SDL...
Code: Select all
void initClips(){
int val = 0;
for(int y = 0; y <=11; y++){
for(int x = 0; x <= 3; x++){
clip[val].h = 32;
clip[val].w = 32;
clip[val].x = x*32;
clip[val].y = y*32;
val++; //try this
}
}
}
Gyro Sheen wrote:you pour their inventory onto my life
IRC wrote: <sparda> The routine had a stack overflow, sorry.
<sparda> Apparently the stack was full of shit.
- ibly31
- Chaos Rift Junior
- Posts: 312
- Joined: Thu Feb 19, 2009 8:47 pm
- Current Project: Like... seven different ones
- Favorite Gaming Platforms: Xbox 360, Gamecube
- Programming Language of Choice: C++, ObjC
- Location: New Jersey.
Re: 2 Questions on SDL...
OH sorry, um, Damn, I actually was testing around, to see if it would work with "val = val + 1" instead of "val++" and I didn't want you guys bitching at me, so I change it to val++, and i forgot the val =... and thats not the error. I dont under-effin-stand! x*y are both ints... and val is an int too
Website/Tumblr
My Projects
The best thing about UDP jokes is that I don’t care if you get them or not.
- Kros
- Chaos Rift Regular
- Posts: 136
- Joined: Tue Feb 24, 2009 4:01 pm
- Current Project: N/A
- Favorite Gaming Platforms: PC, Playstation/2/3
- Programming Language of Choice: C++
- Location: Oregon,USA
- Contact:
Re: 2 Questions on SDL...
Setup some breakpoints and run through it a few times. The debugger is there for a reason.ibly31 wrote:OH sorry, um, Damn, I actually was testing around, to see if it would work with "val = val + 1" instead of "val++" and I didn't want you guys bitching at me, so I change it to val++, and i forgot the val =... and thats not the error. I dont under-effin-stand! x*y are both ints... and val is an int too
YouTube ChannelIsaac Asimov wrote:Part of the inhumanity of the computer is that, once it is competently programmed and working smoothly, it is completely honest.
- ibly31
- Chaos Rift Junior
- Posts: 312
- Joined: Thu Feb 19, 2009 8:47 pm
- Current Project: Like... seven different ones
- Favorite Gaming Platforms: Xbox 360, Gamecube
- Programming Language of Choice: C++, ObjC
- Location: New Jersey.
Re: 2 Questions on SDL...
Oh duh... I made it SDL_Rect clip[41] and it was trying to write 44 elements. Sorry, lol even sorry-er to my heart, my blood pressure was like *2.
EDIT:
EDIT:
I'm fullscreening the window, so it errors if I try to debug... =(Kros wrote:Setup some breakpoints and run through it a few times. The debugger is there for a reason.ibly31 wrote:OH sorry, um, Damn, I actually was testing around, to see if it would work with "val = val + 1" instead of "val++" and I didn't want you guys bitching at me, so I change it to val++, and i forgot the val =... and thats not the error. I dont under-effin-stand! x*y are both ints... and val is an int too
Website/Tumblr
My Projects
The best thing about UDP jokes is that I don’t care if you get them or not.
- Kros
- Chaos Rift Regular
- Posts: 136
- Joined: Tue Feb 24, 2009 4:01 pm
- Current Project: N/A
- Favorite Gaming Platforms: PC, Playstation/2/3
- Programming Language of Choice: C++
- Location: Oregon,USA
- Contact:
Re: 2 Questions on SDL...
You can remove the fullscreen option for debugging purposes.ibly31 wrote:I'm fullscreening the window, so it errors if I try to debug... =(
Anyway, glad you figured it out.
YouTube ChannelIsaac Asimov wrote:Part of the inhumanity of the computer is that, once it is competently programmed and working smoothly, it is completely honest.
- ibly31
- Chaos Rift Junior
- Posts: 312
- Joined: Thu Feb 19, 2009 8:47 pm
- Current Project: Like... seven different ones
- Favorite Gaming Platforms: Xbox 360, Gamecube
- Programming Language of Choice: C++, ObjC
- Location: New Jersey.
Re: 2 Questions on SDL...
Hmm, now text isn't working: is there a way to draw text without the sdl_ttf extention?
Website/Tumblr
My Projects
The best thing about UDP jokes is that I don’t care if you get them or not.
- wtetzner
- Chaos Rift Regular
- Posts: 159
- Joined: Wed Feb 18, 2009 6:43 pm
- Current Project: waterbear, GBA game + editor
- Favorite Gaming Platforms: Game Boy Advance
- Programming Language of Choice: OCaml
- Location: TX
- Contact:
Re: 2 Questions on SDL...
It's basically an array of booleans. And you can use the SDL constants. For example, for the up key:ibly31 wrote:So, how do I know which key is which in the array? Is there a specific list?
So if I'm checking for up, and its 3rd in the list, would i do *psuedo code*
if(keystatearray[3] == 1){
movecharacterup();
}
Code: Select all
if(keystates[SDLK_UP]){
movecharacterup();
}
The novice realizes that the difference between code and data is trivial. The expert realizes that all code is data. And the true master realizes that all data is code.
- ibly31
- Chaos Rift Junior
- Posts: 312
- Joined: Thu Feb 19, 2009 8:47 pm
- Current Project: Like... seven different ones
- Favorite Gaming Platforms: Xbox 360, Gamecube
- Programming Language of Choice: C++, ObjC
- Location: New Jersey.
Re: 2 Questions on SDL...
What size sprites is the ES team using? I'm using 32x32 is that the way to go?
Website/Tumblr
My Projects
The best thing about UDP jokes is that I don’t care if you get them or not.