I'm working on a mobile game that involves a breaking wall. I have my sprites set to change on an alarm. I created an object and placed it in the room with no sprite to handle the event triggers since I thought it might be the creation code for the room that was causing problems. I.E. (Creation code was a bad place to execute)
The creation code for the object sets the alarm to 60
The code I'm using is linked to alarm[0] here:
var WallBreakVal
WallBreakVal = random_range(1, 9);
with(Wall_tiles1)
{
if WallBreakVal = 1
{
sprite_index = Wall2
}
}
with(Wall_tiles2)
{
if WallBreakVal = 2
{
sprite_index = Wall2
}
}
with(Wall_tiles3)
{
if WallBreakVal = 3
{
sprite_index = Wall2
}
}
with(Wall_tiles4)
{
if WallBreakVal = 4
{
sprite_index = Wall2
}
}
with(Wall_tiles5)
{
if WallBreakVal = 5
{
sprite_index = Wall2
}
}
with(Wall_tiles6)
{
if WallBreakVal = 6
{
sprite_index = Wall2
}
}
with(Wall_tiles7)
{
if WallBreakVal = 7
{
sprite_index = Wall2
}
}
with(Wall_tiles8)
{
if WallBreakVal = 8
{
sprite_index = Wall2
}
}
with(Wall_tiles9)
{
if WallBreakVal = 9
{
sprite_index = Wall2
}
}
alarm[0] = 5*room_speed;
The problem was the random_range function. Irandom function returns an integer instead of the entire range
Related
var xpos = 0;
var ypos = 0;
xpos = obj_magnet.x;
ypos = obj_magnet.y;
if (xpos > 435 && xpos < 704 && ypos > 350 && ypos < 640)
{
with(obj_lamp)
{
instance_change(obj_lamp_light, true);
}
if obj_lamp_light.image_index == 5
{
obj_lamp_light.image_speed = 0;
}
with(obj_arrow)
{
instance_change(obj_arrow_move_one_direction, true);
}
if obj_arrow_move_one_direction.image_index == 4
{
obj_arrow_move_one_direction.image_speed = 0;
}
with(obj_arrow_move_opposite_direction)
{
instance_change(obj_arrow, true);
}
exit;
}
else
{
with(obj_lamp_light)
{
instance_change(obj_lamp, true);
}
with(obj_arrow_move_one_direction)
{
instance_change(obj_arrow_move_opposite_direction, true);
if obj_arrow_move_opposite_direction.image_index == 4
{
obj_arrow_move_opposite_direction.image_speed = 0;
}
}
exit;
}
This is a game which I am trying to create where the obj_arrow_move_opposite_direction and obj_arrow_move_one_direction contains 5 sub images and the obj_lamp_light contains 5 sub images.
You stated that each object contains 5 sub-images, correct? Looks like you're looking for a nonexistent sub-image (5) on line 7.
This appears to be a simple typo, but if not it's important to note that image_index starts at 0. So 5 images would be 0-4, rather than 1-5.
var xpos=0;
var ypos=0;
xpos=obj_magnet.x;
ypos=obj_magnet.y;
if(xpos>435&&xpos<704&&ypos>350&&ypos<640) { with(obj_lamp){
instance_change(obj_lamp_light,true);} if
obj_lamp_light.image_index==5{ obj_lamp_light.image_speed=0;} // should be object_lamp_light.image_index == 4
with(obj_arrow){
instance_change(obj_arrow_move_one_direction,true);}
if obj_arrow_move_one_direction.image_index==4{
obj_arrow_move_one_direction.image_speed=0;}
with(obj_arrow_move_opposite_direction){
instance_change(obj_arrow,true);}
exit;
}
else{
with(obj_lamp_light){
instance_change(obj_lamp,true);}
with(obj_arrow_move_one_direction){
instance_change(obj_arrow_move_opposite_direction,true);
if obj_arrow_move_opposite_direction.image_index==4{
obj_arrow_move_opposite_direction.image_speed=0;}}
exit;
}
Better yet, if you're checking to make sure that the object's image_indexes are equal to the last sub-image you could use image_number and subtract by one. This way if you ever add more sub-images you could ensure your code is still checking for the last frame.
I use this on event create to change background during game play. But won't change the background, any idea?
seconds = current_second;
if seconds < 30
{
background_index[0] = background0;
background_visible[0] = true;
}
if seconds > 30
{
background_index[5] = background5;
background_visible[5] = true;
}
// Set background
background_hspeed[0] = -2;
background_hspeed[5] = -2;
I don't understand your goal, so a few examples:
Example 1.
Create event:
background_index[0] = background0;
background_index[1] = background1;
Step event:
seconds = current_second;
if seconds < 30
{
background_visible[0] = true;
background_visible[1] = false;
}
else
{
background_visible[0] = false;
background_visible[1] = true;
}
Example 2. Same, but using alarm
Create event:
background_index[0] = background0;
background_index[1] = background1;
event_perform(ev_alarm, 0);
Alarm 0 event:
seconds = current_second;
if seconds < 30
{
background_visible[0] = true;
background_visible[1] = false;
}
else
{
background_visible[0] = false;
background_visible[1] = true;
}
alarm[0] = room_speed * 30;
Example 3. Other idea...
Create event:
background_index[0] = background0;
background_index[1] = background1;
background_visible[0] = true;
background_visible[1] = true;
event_perform(ev_alarm, 0);
Alarm 0 event:
seconds = current_second;
if seconds < 30
{
background_index[0] = background0;
background_index[1] = background1;
}
else
{
background_index[0] = background1;
background_index[1] = background0;
}
background_x[0] = 0;
background_x[1] = 0;
background_hspeed[0] = 0;
background_hspeed[1] = -2;
alarm[0] = room_speed * 30;
If you need to change backgrounds many times then you need use step event or alarms, because create event does it only once. Also when you use scrolling, you need remember that after some time x position of the background will be outside a screen, so you can't see background (except cases when your background is tiled).
I want to display data from database. There is no TableView in javaFx 1.3 so I used ListView. But, when I put textbox in the listview, it does not perform well. I get problems in fetching data. Can anyone give me a code for listview with a textbox in it and it also fetches and updates data.
var lv_dept_nm:String = "";
var lv_dept_des:String = "";
var lv_dept_name:TextBox;
var lv_dept_desc:TextBox;
var lv_dept_upBtn: Button;
var lv_dept_flag:Boolean = false;
var lv_dept_ind: Integer;
var lv_dept_len: Integer = 0;
var lv_dept_size:Integer = 0;
function removeLastChar(str: String)
{
var string;
if(str != "")
{
string = str.substring(0, str.length()-1);
}
else
{
string = str;
}
return string;
}
var viewDepartmentListView: ListView = ListView
{
items: bind [dept_choicebox_item]
layoutInfo: LayoutInfo{height:bind lv_dept_size}
layoutX: 170
layoutY: 150
width: 500
cellFactory: function() {
var listCell: ListCell;
if(dept_choicebox_item.size() > 5)
{
lv_dept_size = 55 * 5;
}
else
{
lv_dept_size = 55 * dept_choicebox_item.size();
}
listCell = ListCell {
node : HBox {
width: 200
content: [
VBox {
spacing: 10
content: [
Label {
text: bind dept_choicebox_item[listCell.index]
visible: bind not listCell.empty and not lv_dept_flag or not listCell.selected or (lv_dept_ind != listCell.index)
}
lv_dept_name = TextBox
{
promptText: bind dept_choicebox_item[listCell.index]
onKeyPressed: function(ke: KeyEvent)
{
if(ke.code.toString() == "VK_BACK_SPACE")
{
lv_dept_len = lv_dept_nm.length();
lv_dept_nm = removeLastChar(lv_dept_nm);
}
}
onKeyTyped: function(e:KeyEvent)
{
if(lv_dept_len != 0)
{
lv_dept_len = 0;
}
else if(lv_dept_nm == "")
{
lv_dept_nm = e.char;
}
else
{
lv_dept_nm = '{lv_dept_nm}{e.char}';
}
}
columns: 12
visible:bind not listCell.empty and lv_dept_flag and listCell.selected and (lv_dept_ind == listCell.index)
}
]
}
VBox {
spacing: 10
content: [
Label {
text: bind description[listCell.index]
visible: bind not listCell.empty and not lv_dept_flag or not listCell.selected or (lv_dept_ind != listCell.index)
}
lv_dept_desc = TextBox
{
promptText: bind description[listCell.index]
onKeyPressed: function(ke: KeyEvent)
{
if(ke.code.toString() == "VK_BACK_SPACE")
{
lv_dept_len = lv_dept_des.length();
lv_dept_des = removeLastChar(lv_dept_des);
}
}
onKeyTyped : function(e: KeyEvent)
{
if(lv_dept_len != 0)
{
lv_dept_len = 0;
}
else if(lv_dept_des == "")
{
lv_dept_des = e.char;
}
else
{
lv_dept_des = '{lv_dept_des}{e.char}';
}
}
columns: 12
visible:bind not listCell.empty and lv_dept_flag and listCell.selected and (lv_dept_ind == listCell.index)
}
]
}
VBox{
spacing: 10
content: [
Button {
vpos: VPos.TOP;
text: "Edit"
visible: bind not listCell.empty and (not lv_dept_flag or not listCell.selected or (lv_dept_ind != listCell.index))
action: function() {
lv_dept_ind = listCell.index;
lv_dept_flag = true;
}
}
lv_dept_upBtn = Button {
vpos: VPos.TOP;
text: "Update"
visible: bind not listCell.empty and lv_dept_flag and listCell.selected and (lv_dept_ind == listCell.index)
action: function() {
cs = cn.prepareCall("call update_dept(?,?,?)");
cs.setString(1, '{dept_choicebox_item[listCell.index]}');
cs.setString(2, '{lv_dept_nm}');
cs.setString(3, '{lv_dept_des}');
cs.executeUpdate();
dept_choicebox_item[listCell.index] = lv_dept_nm;
description[listCell.index] = lv_dept_des;
lv_dept_flag = false;
lv_dept_nm = "";
lv_dept_des = "";
}
}
]
}
VBox{
spacing: 10
content: [
Button {
vpos: VPos.TOP;
text: "Delete"
visible: bind not listCell.empty and (not lv_dept_flag or not listCell.selected or (lv_dept_ind != listCell.index))
action: function() {
cs = cn.prepareCall("call delete_dept(?)");
cs.setString(1,'{dept_choicebox_item[listCell.index]}');
cs.executeUpdate();
delete dept_choicebox_item[listCell.index] from dept_choicebox_item;
delete description[listCell.index] from description;
lv_dept_size = 55 * dept_choicebox_item.size();
}
}
]
}
]
}
}
}
visible:true;
};
I need to write text in green or red based on:
if(str > 0)
{
document.getElementById('change').style.color = "Green";
document.getElementById('change').innerHTML = html[1];
}
else
{
document.getElementById('change').style.color = "Red";
document.getElementById('change').innerHTML = html[1];
}
str = html[2];
str = str.replace("+","");
str = str.replace("-","");
if(str > 0)
{
document.getElementById('changePercent').style.color = "Green";
document.getElementById('changePercent').innerHTML = html[2];
}
else
{
document.getElementById('changePercent').style.color = "Red";
document.getElementById('changePercent').innerHTML = html[2];
}
But for values -17.91, -5.61, i get both values in the green. Where is the error?
var value = $('p').text();
if (value > 0){
$('p').css('color','green');
}
else {
$('p').css('color','red');
}
Simple jQuery
It could be something bizarre about your variable type. I'm only suspicious because your variable is called str.
What really happens to the currently executing request in IIS during a file upload, when the upload length exceed configured maxRequestLength.
Tried hard to find a decent article that talks about that, but there are none!!
Thanks
This is what exactly happens:
In class HttpRequest and in method GetEntireRawContent this condition is checked and will throw an exception:
if (length > maxRequestLengthBytes)
{
throw new HttpException(System.Web.SR.GetString("Max_request_length_exceeded"), null, 0xbbc);
}
Here is the whole of the method if you find useful:
private HttpRawUploadedContent GetEntireRawContent()
{
if (this._wr == null)
{
return null;
}
if (this._rawContent == null)
{
HttpRuntimeSection httpRuntime = RuntimeConfig.GetConfig(this._context).HttpRuntime;
int maxRequestLengthBytes = httpRuntime.MaxRequestLengthBytes;
if (this.ContentLength > maxRequestLengthBytes)
{
if (!(this._wr is IIS7WorkerRequest))
{
this.Response.CloseConnectionAfterError();
}
throw new HttpException(System.Web.SR.GetString("Max_request_length_exceeded"), null, 0xbbc);
}
int requestLengthDiskThresholdBytes = httpRuntime.RequestLengthDiskThresholdBytes;
HttpRawUploadedContent data = new HttpRawUploadedContent(requestLengthDiskThresholdBytes, this.ContentLength);
byte[] preloadedEntityBody = this._wr.GetPreloadedEntityBody();
if (preloadedEntityBody != null)
{
this._wr.UpdateRequestCounters(preloadedEntityBody.Length);
data.AddBytes(preloadedEntityBody, 0, preloadedEntityBody.Length);
}
if (!this._wr.IsEntireEntityBodyIsPreloaded())
{
int num3 = (this.ContentLength > 0) ? (this.ContentLength - data.Length) : 0x7fffffff;
HttpApplication applicationInstance = this._context.ApplicationInstance;
byte[] buffer = (applicationInstance != null) ? applicationInstance.EntityBuffer : new byte[0x2000];
int length = data.Length;
while (num3 > 0)
{
int size = buffer.Length;
if (size > num3)
{
size = num3;
}
int bytesIn = this._wr.ReadEntityBody(buffer, size);
if (bytesIn <= 0)
{
break;
}
this._wr.UpdateRequestCounters(bytesIn);
this.NeedToInsertEntityBody = true;
data.AddBytes(buffer, 0, bytesIn);
num3 -= bytesIn;
length += bytesIn;
if (length > maxRequestLengthBytes)
{
throw new HttpException(System.Web.SR.GetString("Max_request_length_exceeded"), null, 0xbbc);
}
}
}
data.DoneAddingBytes();
if ((this._installedFilter != null) && (data.Length > 0))
{
try
{
try
{
this._filterSource.SetContent(data);
HttpRawUploadedContent content2 = new HttpRawUploadedContent(requestLengthDiskThresholdBytes, data.Length);
HttpApplication application2 = this._context.ApplicationInstance;
byte[] buffer3 = (application2 != null) ? application2.EntityBuffer : new byte[0x2000];
while (true)
{
int num7 = this._installedFilter.Read(buffer3, 0, buffer3.Length);
if (num7 == 0)
{
break;
}
content2.AddBytes(buffer3, 0, num7);
}
content2.DoneAddingBytes();
data = content2;
}
finally
{
this._filterSource.SetContent(null);
}
}
catch
{
throw;
}
}
this._rawContent = data;
}
return this._rawContent;
}